Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java Swing
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 2-Mar-10 23:02pm
Edited 3-Mar-10 20:35pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Put your javax.swing.JPanel on a javax.swing.JScrollPane like this:
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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 4 Mar 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100