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?

The panel container should have a layout set like BorderLayout for instance.
panel.setLayout(new BorderLayout());
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.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With