Re: Please...Applet frame resize problem

From: Kevin (somewhere_at_overtherainbow.com)
Date: 12/12/03


Date: Fri, 12 Dec 2003 03:59:18 GMT

I didn't think anyone saw my first thread when I posted it, so I posted it
one last time.

Anyways, I see what your saying about pack() not having any dimensional
object to pack and therefore not adjusting the frame accordingly. So I tried
it without pack() and the frame goes to the proper size, but doesn't display
my "hello world" string.
I tried using a panel but still couldn't see my "hello world"

All I'm trying to do is open a window that displays my applet and lets me
display images and draw a few things.
Is there a easier way?

"Andrew Thompson" <andrew64@bigNOSPAMpond.com> wrote in message
news:YJYBb.48477$aT.9439@news-server.bigpond.net.au...
> "Andrew Thompson" <andrew64@bigNOSPAMpond.com> wrote in message
> news:b2UBb.48123$aT.6263@news-server.bigpond.net.au...
> > "Kevin" <somewhere@overtherainbow.com> wrote in message
> > news:H9TBb.54672$bC.13348@clgrps13...
> > > It should be real easy but I'm having troubles.
> > >
> > > I can't seem to get this darn frame to resize (or setsize) when the
> applet
> > > is launched. All I get is a little frame window which I can then
> maximize
> > > and see my applet. I think I have tried ever possible combination of
> the
> > > Frame methods.
> > >
> > > Could someone please lend a helping hand please don't make me beg.
> > > Here is my watered down code.
> > >
> > > import java.awt.*;
> > >
> > > public class test extends java.applet.Applet {
> > > Image currentimg;
> > > Graphics currentGraphics;
> > > Frame myframe;
> > > static Dimension d;
> > >
> > >
> > > public void init() {
> > > myframe = new Frame("Test Applet");
> > > d = Toolkit.getDefaultToolkit().getScreenSize();
> > > myframe.add(this);
>
> And I should add that you are trying to
> add an applet whoich currently resides
> in a browser, into the frame you just
> created. You cannot do that.
> (Or at least, not successfully)
>
> > > myframe.setSize(d.width, d.height);
> >
> > ..this becomes irrelevant
> >
> > > myframe.setVisible(true);
> > > myframe.pack();
> >
> > ..here. Once you call 'pack', the method
> > asks the component what size it _wants_ to
> > be. Since all you have added at this point
> > is an applet (with nothing in it), it says it's
> > preferred size is zero..
> >
> > OTOH, if you had added a Panel who's
> > preferredSize returned the size you want the
> > rendering to be, it would be that size.
> >
> > > myframe.show();
> > > currentGraphics = getGraphics();
> > > paint(currentGraphics);
> > > }
> >
>
> ..But then. You seem to have ignored me and
> posted under a separate thread..
> 'Problem resizing applet frame', so I doubt that
> you will either respond to, or learn anything from,
> your messages here.
>
> --
> Andrew Thompson
> * http://www.PhySci.org/ PhySci software suite
> * http://www.1point1C.org/ 1.1C - Superluminal!
> * http://www.AThompson.info/andrew/ personal site
>
>



Relevant Pages