Eclipse 中的 Java Applet Windows 大小 [英] Java Applet Windows size in Eclipse

查看:28
本文介绍了Eclipse 中的 Java Applet Windows 大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将 Applet 窗口的大小设置为 500 x 500,但我无法实现.这是我的代码,

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

当我在 Eclipse 中按下 CTRL+F11 时,我得到大小为 200 x 200 的输出窗口,为什么我尝试运行程序 5 到 10 次,有时窗口返回 500 x 500 大小,而有时窗口返回大小为 200 x 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.

我不明白为什么要更改窗口的大小,因为我根本没有更改任何代码.我希望大小保持在 500 x 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->Parameters"更改小程序大小.我认为是这个问题,因为默认值eclipse中java小程序大小为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.

希望它会有所帮助:类似问题

这篇关于Eclipse 中的 Java Applet Windows 大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆