my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes setSize() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "setSize()" Watch "setSize()" New topic
Author

setSize()

Simon Whitehouse
Greenhorn

Joined: Dec 10, 2001
Posts: 12
Hi Folks
Can somebody explain to me why the setSize() at //1 appears to have no effect on the Frame that is produced by this code. I think that it is setting the size because if I add the line
System.out.println(this.getSize());
after //1 then it prints out the dimensions that I am trying to set it to. But the frame produced is miniscule

Thanks
Simon
Jim Hall
Ranch Hand

Joined: Nov 29, 2001
Posts: 162
Because the method pack() was called after you set the size.
From API:
public void pack()
Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. If the window and/or its owner are not yet displayable, both are made displayable before calculating the preferred size. The Window will be validated after the preferredSize is calculated.
Take out pack() and it will be stay the size you set it in the setSize() method.

[This message has been edited by Jim Hall (edited December 18, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setSize()
 
Similar Threads
Click a button to display an image. Trouble with add panel to a frame. Help !!
Intersting Question 4 U
Doubt in AWT
Button not visible inc Frame
Problem regarding Border Layout