This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Layout Problem

Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a total of three classes
two of them extends JPanel
and one of them extends JFrame
Classes Extends to JPanel
Classes Extends to JFrame
There are 2 panels in DerivedNames and both of them are of DerivedLabelText type. They are arranged in GridLayout in DerivedNames.
A Panel of type DerivedNames is placed into Test JFrame and there is null layout. When the frame is resized the panel's size is made equal to JFrame's size.Now the problem is When we resize the Frame i.e. Test the Panel i.e. DerivedNames is also resized but the Panels i.e. DerivedLabelText in DerivedNames does not increases its width or height at that time.
According to me that should have happened due to Layout
The following is the code

I think i have to change the preferred size of the controls and then use pack() method
Is it true But Where should i write this code
I can't find a answer to this question
please help me regarding this
Thanks in advance
Chirag Jakharia
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got myself right by adding a ComponentListener which will fire componentResized event
In this event we will call updateUI() method Which will update the panel according to its Layout
My problem was that despite the size of the panel changes the controls do not change their size according to layout
Now the improved code for DerivedNames is
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!