Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open fourth tab as first tab in JTabbedPane in netbeans

I have a tabbed pane including five tabs on it . This tabbed pane is on a JPanel I use a button on another JPanel to get fourth tab as leading tab . But when I click on the button first tab is still display and I have to move to the fourth one manually . Have any ideas . Thanks in deep.

Button action

Center instance1 = Center.getInstance();
instance1.doClickHistoryBtn();

doClickHistoryBtn() method

public void doClickHistoryBtn(){
    history_btn.doClick();
}

When I execute this doClickHistoryBtn() method , History_panel is loading.

second JPanel (History_panel)

private JPanel history_panel1;
private JPanel history_panel2;
private JPanel history_panel3;
private JPanel history_panel4;
private JPanel history_panel5;

public History_panel()
{
    initComponents();
    setPanels();
}   

private void setPanels(){    

}

first screen image

This is my first screen.

Expected

changed image

Actual

result image

like image 464
Terance Wijesuriya Avatar asked Oct 31 '22 11:10

Terance Wijesuriya


1 Answers

JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setSelectedIndex(3);

Above code will do it In setSelectedIndex() method you have to pass the index of the tabbedpane you want to set as default. And it will open that pane whose index u will providing as argument to the setSelectedIndex().

like image 95
Mrinmoy Avatar answered Nov 14 '22 14:11

Mrinmoy