user1155413
user1155413

Reputation: 169

auto resize JTabbedPane

Is there any way to autoresize a JTabbedPane to the same size that the JFrame has? I'm using netbeans to create the swing interface and I can't figure out whether this is a property that I can set through the GUI designer or if I have to do it programmatically. If I need to do it programatically, netbeans doesn't allow users to modify the auto generated UI code.

Thanks a lot in advance

Upvotes: 2

Views: 6058

Answers (1)

yggdraa
yggdraa

Reputation: 2050

The Visual Guide to Layout Managers should be useful for understanding how components are arranged in container. For your task I would use BorderLayout and placed the JTabbedPane into it's center area. For example:

 frame.getContentPane().setLayout(new BorderLayout());
 frame.getContentPane().add(pane, BorderLayout.CENTER);

In netbeans you just change your frame layout to BorderLayout and after that in properties for the JTabbedPane set layout constraint CENTER

Upvotes: 3

Related Questions