Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2003

Tip: Looking for answers? Try searching our database.

Very simple Java AWT Frame resize question

Thread view: 
Gregory Hassett - 21 Nov 2003 16:36 GMT
In the following code, I create an awt Frame. Unfortunately, when I
run the resulting Java application (on Windows) and use the mouse to
resize the window, none of the Frame's resize/setSize methods get
called. Can anyone explain why this is?

Thanks

Greg

import java.awt.* ;

public class Junk extends Frame
{
public static void main (String args[])
{
Junk j = new Junk ();

j.show ();
}

public void resize(Dimension arg0)
{
super.resize(arg0);
}

public void resize(int arg0, int arg1)
{
super.resize(arg0, arg1);
}

public void setSize(Dimension arg0)
{
super.setSize(arg0);
}

public void setSize(int arg0, int arg1)
{
super.setSize(arg0, arg1);
}
}
A. Bolmarcich - 21 Nov 2003 17:25 GMT
> In the following code, I create an awt Frame. Unfortunately, when I
> run the resulting Java application (on Windows) and use the mouse to
> resize the window, none of the Frame's resize/setSize methods get
> called. Can anyone explain why this is?

It happens because using the mouse to resize the window invokes a method
of a java.awt.peer.Frame object rather than a java.awt.Frame.  A
java.awt.Frame class handles the implementation independent behavior of
a frame, while the corresponding peer class handles the implementation
dependent behavior.  Conceptually, the same java.awt.Frame class can be
used by all implementations of Java.  Each implementation will have to
provide the correspoinding peer class.

If you want to be informed that the size of a frame has changed, add
a ComponentListener to the frame.  The componentResized(ComponentEvent)
method of the ComponentListener will be invoked after the size has
changed.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.