Archived

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

[java] auto-resizing an applet

This topic is 5530 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);
}
}


_______________________
http://mill.3dfxsweden.net

Share this post


Link to post
Share on other sites
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
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
Hi,

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:
wp.netscape.com/eng/mozilla/3.0/handbook/javascript.

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