Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,
I'm trying to show two images in different Jpanel by browsing dialog using Java Swing window. But the panels are not being in its position after browsing the second image. Also the size of the image getting large without scroll bar. What type of layout i have to use.i need to change the image whenever browsing new one with a fixed size and with scroll bar. Please help me by posting your ideas.

Hi,
i have splitted one panel into fout parts by grid layout. i need to show two images in top two parts.
If the mge size is different the image is hiding inside of panel. If i used scroll bar its not aligning
properly what type of layout should i use. how to set scroll bar for inner panels.
Posted
Updated 3-Mar-10 19:35pm
v2

Put your javax.swing.JPanel on a javax.swing.JScrollPane like this:
Java
JPanel pnlImage = new JPanel(new BorderLayout());
JScrollPane spnImage = new JScrollPane(pnlImage);

Then instead of placing the panel pnlImage on your container or frame, place the scroll pane spnImage on it.
 
Share this answer
 
From the previuous answer you were given a HUGE clue. Use a ScrollPanel, everything goes on the panel and it manages the scrolling for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900