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 / General / April 2006

Tip: Looking for answers? Try searching our database.

JFrame question!

Thread view: 
DBC User - 24 Apr 2006 17:43 GMT
Hello,

I am starting Java recently and I am learning, so if someone can help
me with the following would be great.

I have a JFrame, which has gridlayout. One of the grid has 2 check
boxes. What I want is, if a check box is clicked, I want to expand the
JFrame dynamically and add another JPanel to the GridLayout at the
bottom and when the check box is unchecked, I want the JFrame to go
back to the original state (with out the added JPanel). How can I do
it? I want the transition of the panel adding and removing smooth.

Is there a way to do it?

Thanks.
Homer - 24 Apr 2006 20:47 GMT
I am not %100 sure about this (I should test it) but what you can do
is:

- define your grid with reserved size for your JPanel.
- By clicking CheckBox Add JPanel object to the Grid.
- Update JFrame to be resized. (setPreferdSize, validate?)

Or try setVisible() for your JPanel.

Is this in SetSwing Example coming with JDK?
Josh Falter - 25 Apr 2006 14:41 GMT
The JFrame can change size during execution using the setSize()
function.

There are a few routes you can go with dynamically adding the JPanel to
your JFrame.
I would not recommend adding it using GridLayout though, which does not
respect the sizes you request.

GridLayout is great for keeping components like JCheckBoxes or JButtons
organized, but is not good for adding containers that probably dont
need to be the same size as other components such as a JPanel, although
you may be envisioning adding a smaller JPanel than what I am
picturing.

After changing the contents of the JFrame, you can update it using
invalidate()
validate()
repaint()


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



©2008 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.