GeeCON Prague 2014*
The moose likes Applets and the fly likes how to override width and height params in applet tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Applets
Bookmark "how to override width and height params in applet tag" Watch "how to override width and height params in applet tag" New topic
Author

how to override width and height params in applet tag

Ilja Smoli
Ranch Hand

Joined: Dec 02, 2001
Posts: 64
Hi
I want to set size for applet in init() method, cause its based on some dynamic data.
i tryed resize(), setSize(), setBounds(), nothing is working.
Applet opens always with size defined in html file.
btw in appletviewer everything is working fine with resize() func.
Thx in advance
[ January 27, 2004: Message edited by: Ilja Smoli ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Sorry -- that's just how it works. The web browser lays out the page before your applet is even constructed. By the time init() runs, the page is already displayed, and you can't rearrange it.


[Jess in Action][AskingGoodQuestions]
Ilja Smoli
Ranch Hand

Joined: Dec 02, 2001
Posts: 64
well, for what all this methods such resize() are?
main idea of applets as i understand to be used in browsers..
[ January 27, 2004: Message edited by: Ilja Smoli ]
Brian Pipa
Ranch Hand

Joined: Sep 29, 2003
Posts: 299
You could display your applet outside of the browser (like in a JFrame) with just a stub panel in the browser that says something like "applet is being shown outside the browser" then you could resize it all you want.
brian


My Java Freeware:<br />MACCC - <a href="http://maccc.pipasoft.com" target="_blank" rel="nofollow">http://maccc.pipasoft.com</a><br />Nator - <a href="http://nator.pipasoft.com" target="_blank" rel="nofollow">http://nator.pipasoft.com</a>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16101
    
  21

Unfortunately, Sun used some method names for their own internal functions that all the other windowing systems used for commonly used public functions . I went through a world of grief over that before I finally broke down and bought a decent book on the topic.
Applets are not allowed to resize themselves for several reasons. One of which is that they're not expected to know a whole lot about the overall environment of the windows they live in or what else may be sharing it.
You can get around the problem if you set up a javascript in the web page that is used to get to the actual page containing the applet. Just use the javascript to get the window's current dimensions and pass them to the server and use them to build the applet invocation tags.
It's not a perfect solution, since it can't track window resizing, but it's about as good as you can do.


Customer surveys are for companies who didn't pay proper attention to begin with.
Miro Ricco
Ranch Hand

Joined: Apr 16, 2002
Posts: 40
How is it with relative width and height of an applet ?
Is it supported by every browser and Java version or not ?
Paul Hilliar
Greenhorn

Joined: Jul 11, 2003
Posts: 9
See: http://blog.taragana.com/index.php/archive/resizing-applets-dynamically-within-browser-frames/

This works great in IE6
 
GeeCON Prague 2014
 
subject: how to override width and height params in applet tag