Joined: Sat Jan 19, 2013 12:15 am
Problem when using layour with JTabbedPane and JScrollPane
I'm not sure if this is bug or not, and if it it's swing or MiG bug, but I thought I could ask here since folks over on stackoverflow.com suspect it to be a bug.
I have sent a ticket, but I'd like to know if there is a workaround for now.
I have a JFrame with it's content pane. JMenuBar is docked on the north of the pane and JLabel (status bar of sorts) on the south.
In the middle is a JTabbedPane. Each tab is a "document". It contains a JScrollBar and a JPanel in it's viewport.
It goes on and on (JPanel of the viewport has more JPanels, that can have more of them, etc...), but for this example, lets just say that that JPanel (in the viewport) can, or cannot fit into the window space (so it cannot, or can force scrollBars to be represented on the screen).
When it fits the window, everyting is fine, but as soon as I set it's height to be too hight to fit inside a window, JMenuBar gets squished on the top.
I'd like to prevent that (without having to specify the absolute height for the JMenuBar, it'd probably work, but it's kind of cheap), since it shouldn't happen in the first place.
Here's SCCE (It's not really short, but you only need to look at the lines 32 to 112, and I have marked all the lines that have something to do with layout with //TODO). Also, to see when problem occurs or when it doesn't occur, change height value in the line 83 inbetween 200 and 2000.
The code is in the attachement.
File comment: This is the code
code.java [4.18 KiB]
Downloaded 407 times
Joined: Mon Dec 06, 2004 4:24 pm
Re: Problem when using layour with JTabbedPane and JScrollPa
The Menu doesn't have a minimum size and it therefore gets compressed.
In the menu class add this
public Dimension getMinimumSize()
or when adding the menu to MigLayout add "hmin pref".