How do I specify the height and width of an Applet?

From: TheOfficeClerk (joey.mouha_at_favv.be)
Date: 06/16/04

  • Next message: Ricketts: "Newbie Help"
    Date: 16 Jun 2004 05:19:52 -0700
    
    

    Hi all,

    I'm faced with a similar problem that was posted by Stefan Pauls
    earlier here on this newsgroup.

    How do I specify the height and width of an Applet, without specifying
    these settings in the browser?

    My Applet is a simple Applet (BorderLayout) with 4 Buttons and a
    custom Canvas class in the center. This custom Canvas must be 800x600
    pixels exact. The Buttons can be whatever size they want or need to
    be.

    I've tried various ways to achieve the correct layout and size, but
    cannot get it to work. Overriding getMaximumSize, getMinimumSize,
    getPreferredSize, getWidth, getHeight etc... did not work.

    Swing allows me to set the size of an Applet from within the Applet,
    or so it appears, by using this.setSize(this.getPreferredSize()) -
    strange, but it works.

    However, in AWT (we cannot use Swing) I see no means to get the Applet
    to the size I want it to be.

    My final option would be to calculate and specify the height and width
    from withing the HTML page that calls the Applet, but that is not
    really a clean option. Suppose we change the buttons, or the buttons
    are displayed differently in different browsers? Then we would have a
    problem.

    Please note that I am not looking for a way to *resize* an Applet
    after it has already been displayed (I believe this is not possible),
    I just want to specify a size from *within* the Applet.

    Any ideas, suggestions, other solutions?

    Thanks in advance,

    ToC


  • Next message: Ricketts: "Newbie Help"