Sufiyan Ghori
Sufiyan Ghori

Reputation: 18743

Java Applet Windows size in 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

Upvotes: 3

Views: 28821

Answers (3)

enivaldo bonelli
enivaldo bonelli

Reputation: 11

To change the size of the Applet Window, without looking for the eclipse .html is to choose "Run Configurations" in the "Run, '>' icon options " in the eclipse panel. In the configurations choose "Parameters" and set the size of the applet in the two boxes available for 'height' and 'length.' You may leave the box 'name' unfilled.

Upvotes: 1

Hassen Ch.
Hassen Ch.

Reputation: 1751

try this inside the paint method for example

this.setSize(300, 300);

Upvotes: 1

guanda
guanda

Reputation: 126

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

Upvotes: 7

Related Questions