3

Can I put some tabs to the left and others to the right in a JTabbedPane? Or at least to add some tabs, then add an empty space, and then add other tabs?

Thanks!

radonys
  • 597
  • 1
  • 9
  • 20
  • 1
    I'm having difficulty following you. do you want control over the index of a tab? if so, use [insertTab](http://download.oracle.com/javase/6/docs/api/javax/swing/JTabbedPane.html#insertTab%28java.lang.String,%20javax.swing.Icon,%20java.awt.Component,%20java.lang.String,%20int%29) – mre Jun 01 '11 at 14:56
  • @mre no, i want some tabs to appear to the left, and others to the right, but Lord Torgamus says it's not possible. – radonys Jun 01 '11 at 15:04

3 Answers3

3

Use a CardLayout and just add your buttons.

Create a main panel that uses a BorderLayout. Add your CardLayout and cards to the SOUTH. Then create two button panels. One for the WEST and one for the EAST.

Or instead of creating two panels for the buttons you can use a BoxLayout and then add "glue" between the left and right buttons and the layout manager will add space automatically.

camickr
  • 321,443
  • 19
  • 166
  • 288
2

No, unfortunately, those behaviors are not supported by Swing (or SWT, for that matter).

(My interpretation of your question, since there seems to be some confusion, is that you were looking for behavior like this:

tab bar with separated tabs)

Pops
  • 30,199
  • 37
  • 136
  • 151
1

No, I don't think you can. You can try using two tabbed panes added onto a panel or splitpane. For example:

JPanel panel = new JPanel(new GridLayout(1,2));        

JTabbedPane tabs = new JTabbedPane();
tabs.addTab("A", new JPanel());
tabs.addTab("B", new JPanel());
tabs.addTab("C", new JPanel());
panel.add(tabs);        

JTabbedPane tabs2 = new JTabbedPane();
tabs2.addTab("X", new JPanel());
tabs2.addTab("Y", new JPanel());
tabs2.addTab("Z", new JPanel());
panel.add(tabs2);
dogbane
  • 266,786
  • 75
  • 396
  • 414