Tabs are reset

I am creating a GUI where the main window will contain multiple tabs. They should be located next to each other horizontally.

Using this code makes a "collapsed" version where I can switch tabs with 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 to make bookmarks stand next to each other?

enter image description here

+3


source to share


2 answers


The container panel

must have a layout like BorderLayout

.



panel.setLayout(new BorderLayout());

      

+2


source


The exact result depends on several things:

  • TabbedPaneUI framework, AquaTabbedPaneUI

    in Mac OS X.

  • The value set in setTabLayoutPolicy()

    .

  • The preferred content size used when pack()

    is called upon conclusion Window

    .



You can use this example to experiment with different Look & Feel settings. Notice how the preferred content size determines the size of each tab content area.

image

+1


source







All Articles