posted 21 years ago
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....