JFrame没有显示内容,只有空白框

时间:2015-10-11 02:46:01

标签: java swing

所以我正在研究一个实现JFrame来创建城市景观的学校项目。在将构造函数方法更改为类之后,所有显示的都是一个白框。

public CityscapeComponent(int amountStars)
{
    numberOfStars = amountStars;
}

/**
 * This method is invoked by the Java Run-Time whenever the component needs to be redrawn.
 * It does not need to be invoked explicitly.
 *
 */
public void paintComponent(Graphics g)
{
    Graphics2D g2 = (Graphics2D) g;




    Background base = new Background(50);
    Stars starDots = new Stars(100, 5, 5);
    Bridge suspBridge = new Bridge(100);
    Buildings skyscrapers = new Buildings(200);
    Grid mainGrid = new Grid();



    base.draw(g2);
    starDots.draw(g2);
    suspBridge.draw(g2);
    skyscrapers.draw(g2);
    mainGrid.draw(g2);
}

}

所以它以前工作,但现在它没有给我任何语法错误。是的,我有一切正确导入,所有,必须省略一些代码,以避免混淆。

感谢您的帮助。

0 个答案:

没有答案