• 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
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

getScaledInstance() and resize event

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a problem displaying a icon and I appreciate any help
I could get.
I have a app with three panes; top, middle and bottom, each using GridBagLayout.
The top panel (JPanel) displays a JLabel on which I put a icon (.gif). The
original .gif has a width of 200 and height of 450.
I use getScaledInstance() on the image to reduce it to about 200 by 200.
On INITIAL display, everything looks fine, but on a RESIZE the layout manager
tries to display the entire height of 400, so I end up with the top panel
and nothing else.
I can't figure out if it's a problem with the image or my constraint settings
which are as follows:
setLayout( new GridBagLayout() );
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 2;
c.gridheight = 1;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 0.5;
add(TopPanel,c);

c.gridx = 0;
c.gridy = 2;
c.gridwidth = 2;
c.gridheight = 1;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 0;
add(new JPanel(false),c); // Just padding between top and middle
c.gridx = 0;
c.gridy = 4;
c.gridwidth = 2;
c.gridheight = 1;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 0.5;
add(MiddlePanel,c);
c.gridx = 0;
c.gridy = 6;
c.gridwidth = 2;
c.gridheight = 1;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 0;
add(ButtonFrame,c);

Thanks in advance....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic