Discussion:
Does anybody understand the implications of resizing a Frame on a JTabbedPane?
Doug Robinson
2011-02-02 19:43:18 UTC
Permalink
Hello
I have an app with a JTabbedPane and three contained JPanels.
When I resize my application the exposed JPanel in the JTabbedPane
does not adjust. If I drag the side of the window out I can find the
outline of the panel. but but it seems that the window & the panel
are not connected. I tried setting the size of the JTabbedPane &
the JPanel to but this had no affect.
It would be nice if I could resize these things and still have
the nice (??) trim from the panels visible.

Thank you for your time.

dkr
Damian Carey
2011-02-02 21:20:02 UTC
Permalink
Doug,

You need to set the Layout of the JTabbedPane. This is a Java Swing issue
more so than a Netbeans issue. There are multiple Layouts available in Java
- all with pros and cons. If you are using the Netbeans GUI Builder then by
default the Layout will be Matisse / Free Design or whatever they call it
now). It is pretty much WYSIWYG - and as you drag the components around you
will see it trying to attach to the other borders components around it.

If you drag the borders of the JPanel to the border of its container (the
JTabbedPane) it *should* click and latch on.

If you want all three JPanels to (1) be the same size and (2) fill the
JTabbedPane then set the Layout to "Grid". (not GridBag !)

Layouts are very powerful - but they are horrible to get your head wrapped
around. They are especially terrible to describe via email.

There must be some screen casts describing this stuff.

HTH
-Damian
Post by Doug Robinson
Hello
I have an app with a JTabbedPane and three contained JPanels.
When I resize my application the exposed JPanel in the JTabbedPane
does not adjust. If I drag the side of the window out I can find the
outline of the panel. but but it seems that the window & the panel
are not connected. I tried setting the size of the JTabbedPane &
the JPanel to but this had no affect.
It would be nice if I could resize these things and still have
the nice (??) trim from the panels visible.
Thank you for your time.
dkr
Doug Robinson
2011-02-10 17:49:31 UTC
Permalink
Post by Damian Carey
Doug,
You need to set the Layout of the JTabbedPane. This is a Java Swing
issue more so than a Netbeans issue. There are multiple Layouts
available in Java - all with pros and cons. If you are using the
Netbeans GUI Builder then by default the Layout will be Matisse / Free
Design or whatever they call it now). It is pretty much WYSIWYG - and
as you drag the components around you will see it trying to attach to
the other borders components around it.
If you drag the borders of the JPanel to the border of its container
(the JTabbedPane) it *should* click and latch on.
If you want all three JPanels to (1) be the same size and (2) fill the
JTabbedPane then set the Layout to "Grid". (not GridBag !)
Layouts are very powerful - but they are horrible to get your head
wrapped around. They are especially terrible to describe via email.
There must be some screen casts describing this stuff.
HTH
-Damian
Hello
I have an app with a JTabbedPane and three contained JPanels.
When I resize my application the exposed JPanel in the JTabbedPane
does not adjust. If I drag the side of the window out I can find the
outline of the panel. but but it seems that the window & the panel
are not connected. I tried setting the size of the JTabbedPane &
the JPanel to but this had no affect.
It would be nice if I could resize these things and still have
the nice (??) trim from the panels visible.
Thank you for your time.
dkr
Ahh - that seems like a reasonable thing - I'll look into it as soon as
I can get back to it!

Thanks again
dkr

areeda
2011-02-05 03:13:08 UTC
Permalink
I just wrestled with this. I wanted 4 graphs (2x2) of different parameters in a tab and of course multiple tabs. Everything resizing with the window.

The trick for me was to use the GridBox Layout inside a panel that was tied to the tabbed pane. Ooh that sounds a lot more complicated than it is.

I kind of cheated and made a dummy JPanel object, did the layout then copied its InitComponent method into my object that created the JPanel for each tab. Going through how the NB generated code dealt with the layout made it clear.

Hope that helps, at least it should say it can be done.

Joe
Loading...