Reputation: 303
I am creating a GUI where the main window will contain a number of tabs. They should be positioned next to each other horizontally.
Using this code makes a "collapsed" version, where I can toggle the tabs with the arrows.
JTabbedPane tabs = new JTabbedPane();
JPanel tab_virksomheder = new JPanel();
tabs.addTab("Virksomheder", tab_virksomheder);
JPanel tab_praktikpladser = new JPanel();
tabs.addTab("Praktikpladser", tab_praktikpladser);
panel.add(tabs);
How can I make the tabs stand next to each other?
Upvotes: 3
Views: 213
Reputation: 205875
The exact result depends on several things:
The platform's TabbedPaneUI, AquaTabbedPaneUI
on Mac OS X.
The setting supplied to setTabLayoutPolicy()
.
The preferred size of the content, used when pack()
is invoked on the enclosing Window
.
You can use this example to experiment with various Look&Feel settings. Note how the content's preferred size defines the size of each tab's content pane.
Upvotes: 1
Reputation: 32391
The panel
container should have a layout set like BorderLayout
for instance.
panel.setLayout(new BorderLayout());
Upvotes: 2