Click here to Skip to main content
13,050,450 members (88,551 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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.

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 22:02pm
Updated 3-Mar-10 19:35pm
Rate this: bad
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.
Rate this: bad
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 4 Mar 2010
Copyright © CodeProject, 1999-2017
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