List of usage examples for javax.swing JTabbedPane indexOfTabComponent
public int indexOfTabComponent(Component tabComponent)
From source file:components.ButtonTabComponent.java
public ButtonTabComponent(final JTabbedPane pane) { //unset default FlowLayout' gaps super(new FlowLayout(FlowLayout.LEFT, 0, 0)); if (pane == null) { throw new NullPointerException("TabbedPane is null"); }//from ww w. jav a 2 s .com this.pane = pane; setOpaque(false); //make JLabel read titles from JTabbedPane JLabel label = new JLabel() { public String getText() { int i = pane.indexOfTabComponent(ButtonTabComponent.this); if (i != -1) { return pane.getTitleAt(i); } return null; } }; add(label); //add more space between the label and the button label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); //tab button JButton button = new TabButton(); add(button); //add more space to the top of the component setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); }