• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

GridBagLayout "scrunched" together - messy?

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.
I've an applet which throws a JFrame.
The JFrame constains a relatively complex GridBagLayout.
When the JFrame pops up, and before I maximize it, the components appear "scrunched" up, overlapping one another in a mess, as if swing is trying to fit everything into the minimized JFrame.
However, once I maximize the JFrame, the components are laid out as intended.
Why is this so and how can I prevent the JComponents from being scrunched up before maximizing the JFrame?
TIA :-)
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is the initial size of the frame big enough for its content?
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, when the JFrame pops up, it is in a "minimized" form, rather than taking up all the screen real estate. So no, it's not big enough in that sense. Since I maximize it, there's enough screen real estate to lay out the components.
Is there a way I can work around this?
Perhaps put the whole GridBagLayout in a JScrollPane ?
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes that idea is working; it also looks better setting the scrollbar policies to NEVER.
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The idea works well, but the fine-tuning is puzzling.
Following piece of code achieves the desired basic result:

Yet this piece of code, which is nicer but not a show-stopper, throws compile time error:

The compile time error reads:

cannot resolve symbol
symbol : variable ScrollPaneConstants
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[ February 04, 2004: Message edited by: Craig Wood ]
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Craig, for taking time to look at my issue.
Your approach works for me.
It would be nice though to know why ScrollPaneConstants didn't work...
:-)
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look in the JScrollPane api at the setVerticalScrollBarPolicy(int policy) method for a listing of the legal values.
 
I AM MIGHTY! Especially when I hold this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic