View unanswered posts | View active topics It is currently Tue Feb 21, 2017 5:48 am

Reply to topic  [ 2 posts ] 
 Problem when using layour with JTabbedPane and JScrollPane 

Is this a bug?
Yes 0%  0%  [ 0 ]
No 0%  0%  [ 0 ]
Maybe 0%  0%  [ 0 ]
Total votes : 0

 Problem when using layour with JTabbedPane and JScrollPane 
Author Message

Joined: Sat Jan 19, 2013 12:15 am
Posts: 5
Post 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 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 [4.18 KiB]
Downloaded 406 times
Sat Jan 19, 2013 12:21 am
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post 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()
return getPreferredSize();

or when adding the menu to MigLayout add "hmin pref".

Both works.


Fri Feb 22, 2013 4:31 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.