Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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....
 
I think she's lovely. It's this tiny ad that called her crazy:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic