File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes getScaledInstance()  and resize event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "getScaledInstance()  and resize event" Watch "getScaledInstance()  and resize event" New topic
Author

getScaledInstance() and resize event

Duane Riech
Ranch Hand

Joined: Feb 27, 2003
Posts: 52
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: getScaledInstance() and resize event
 
Similar Threads
size of one button is less than expected in GridBagLayout
GridBagLayout...!
How to make the window (JPanel?) bigger in gridbaglayout
GridBagLayout problems
how to fix the JLabel Text value in Swings