java applet 窗口大小,Java小程序窗口的大小在Eclipse

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();

}

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.

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

解决方案

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.

Hope it will helpful:

a similar issue

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值