Jack English
Jack English

Reputation: 107

Java applet setSize not accurate, window too large

I have a Java applet that J am trying to to set to 480, 800 using setSize but the window comes up 487,850 for some reason. here is the code where it is set.

public void init() {
        setSize(480,800);
        setBackground(Color.BLUE);
        setFocusable(true);
        addMouseListener(this);
        addKeyListener(this);
        Frame frame = (Frame) this.getParent().getParent();
        frame.setTitle("SwingBall");
        try {
         base = getDocumentBase();
        } catch (Exception e) {
        // TODO: handle exception
        }
}

There is no other mention of setting size anywhere else in code, any idea as to why this is happening?

Upvotes: 1

Views: 123

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285405

You don't set the size of the applet in the applet itself, and trying to do this will have no effect, as you're finding out. If you want to specify the size of the applet, you do this in the HTML code that calls the applet.

As an aside, your //TODO: handle exception is telling you something important, that you shouldn't leave the catch block empty.

Upvotes: 1

Related Questions