Patrick Reck
Patrick Reck

Reputation: 303

Tabs are collapsed

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?

enter image description here

Upvotes: 3

Views: 213

Answers (2)

trashgod
trashgod

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.

image

Upvotes: 1

Dan D.
Dan D.

Reputation: 32391

The panel container should have a layout set like BorderLayout for instance.

panel.setLayout(new BorderLayout());

Upvotes: 2

Related Questions