[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Please send email if you are having login problems - see the posts below for more info.
Hotmail and Yahoo! users - please see the Hotmail post or the Yahoo! post for information on lost emails.
Resizing a graphic inside a JPanel  XML
Forum Index » GUI Development
Author Message
nt5515

Newbie

Joined: 02/15/2008 09:17:10
Messages: 7
Offline

Hi,
I've set up an array of Jpanels in a grid layout. im trying to insert a graphic into each panel using a loop. i can get the graphic in but it sits in the bottom right of each panel, and i've tried setting the layout and the size but nothing happens.

Is there any way which i can set the graphic to be the same size as the JPanel, so when i resize the window the graphic will resize automaticaly.

Any ideas??
Cheers
stdunbar

Newbie
[Avatar]

Joined: 06/22/2005 14:51:37
Messages: 849
Location: Superior, CO, USA
Offline

I believe that you will have to override the paint() method on JPanel. When it is called you will need to find out the size of the JPanel and resize the image at that time. I think it will be something like the below (warning - untested!)


This message was edited 2 times. Last update was at 02/27/2008 09:25:08


Thanks for using the forums at hotjoe.com
[WWW] [Yahoo!] [ICQ]
 
Forum Index » GUI Development
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2011 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle