Reputation: 7305
I am trying to create a JTabbedPane that will always fill the top part of the Component with the tabs. Like so:
And this is how it look now:
And the code for this part:
JTabbedPane tab = new JTabbedPane();
tab.addTab("Items", items);
tab.addTab("Categories", categories);
setContentPane(tab);
//Also tried to create a JTabbedPane class and see if i could remove the labels and manually add two buttons to the top but without success.
I want the tabs to use up as much space as possible without actually shrinking the content of the panels. So could anyone tell me how to customize the JTabbedPane, the look and feed or just the tabs themselves in order to do that.
Upvotes: 1
Views: 804
Reputation: 324127
The easiest approach is probably to create your own component:
BorderLayout.PAGE_START
. Each of these button will display a specific panel when clicked.CardLayout
. Add this panel to the "main" panel using BorderLayout.CENTER
. Each of these panels will represent a tab.The other option is to look at the TabbedPaneUI
and find a method that paints each tab and modify the code for your requirement.
Upvotes: 3