This topic is now archived and is closed to further replies.


[java] auto-resizing an applet

Recommended Posts

mill-o    122
perhaps something like this?

public void paint(Graphics g) {
Dimension d = getSize();
if (backImage == null || backDimension.width != d.width || backDimension.height != d.height ) {
Image temp = backImage;
backImage = createImage(d.width, d.height);
backDimension = d;
backGraphics = backImage.getGraphics();
if (temp != null)
backGraphics.drawImage(temp, 0, 0, this);


Share this post

Link to post
Share on other sites
misterX    144
no, sorry, it isn''t what i meant.
Let me explain the situation:
There is an applet in a html page. What i want is that the applet take all the place in the html page; and when the page is resized, the applet must also be resized to fit into the page.

Share this post

Link to post
Share on other sites
CaptainJester    523
The applet cannot tell what is going on in the web page. You need to use javascript or VBScript or something similar to detect it and that can resize the applet by changing the values of the width and height parameter in the applet tag. At that point if you listen to component events in the applet, it will then be able to detect the resize and you can react accordingly.

Make it work.
Make it fast.

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post

Link to post
Share on other sites
Petr Stedry    122

maybe a little bit of cooperation between a javascript and the Java applet is necessary ?
Although I encountered a similar problem, I found another way around (moved a lot from the applet to the page using javascript).

IMHO the problem lies with the BROWSER (not the applet) as this is the element that gives "page space" to the applet. So my suggestion is try to find a way to comunicate from javascript to the applet. The applet needs to be notified about the changes in size, so it can take them into account.

Some time ago I foud this site:

But don''t put any hope in MSIE and Java to work together deeper than the plugin (see liveconnect - the reference above). Their "master''s" strategies are incompatible (.

Share this post

Link to post
Share on other sites