Java小程序窗口的大小在Eclipse
我试图用500设置一个小程序窗口500的大小,但我无法做到这一点。
这里是我的code,
I am trying to set the size of an Applet Window to 500 by 500, but I couldn't be able to achieve that. Here is my code,
public void init() {
// Start Screen Color
setBackground(Color.RED);
this.setSize(new Dimension(500,500));
width=getSize().width;
height=getSize().height;
running=false;
repaint();
offscreenImage = createImage(width,height);
offscreenGraphics = offscreenImage.getGraphics();
addKeyListener(this);
addFocusListener(this);
waitingForSpace=false;
repaint();
}
当我pressed CTRL在Eclipse + F11我用200减500的大小而一些得到的输出窗口大小为200,为什么我尝试运行该程序像5至10倍,有时与500的窗口返回时间窗口大小为200 200。
When I pressed CTRL+F11 in Eclipse I get the output Window with size 200 by 200, Why I try to run the program like 5 to 10 times, sometimes the window returns with the 500 by 500 size while some time the window size is 200 by 200.
我不明白为什么窗口的大小改变我,因为我没有改变任何code在所有。
我要的大小500保持在500
I do not understand why the size of the window i changing since I am not changing any code at all. I want the size to remain at 500 by 500
如果你使用Eclipse,你可以从运行配置的Java Applet->参数改变applet的大小。我认为这是问题,因为默认值爪哇在eclipse小程序大小为200 * 200。
If you use eclipse, you can change applet size from the "run configuration" Java Applet->Parameters". I think that's the problem, because the default value of java applet size in eclipse is 200*200.
希望这将有所帮助:
a类似的问题