¿Cómo cambiar pestañas en jTabbedPane haciendo clic en un botón?
Tengo dos JTabbedPanes, JTabbedPane1 y 2 ¿Cómo puedo presionar el botón en JTabbedPane2 para mostrar JTabbedPane1?
Aquí está el código para JTabbedPane:
public class TabbedPane extends JFrame {
public TabbedPane() {
setTitle("Tabbed Pane");
setSize(300,300);
JTabbedPane jtp = new JTabbedPane();
getContentPane().add(jtp);
JPanel1 jp1 = new JPanel1();//This will create the first tab
JPanel jp2 = new JPanel2();//This will create the second tab
//add panel .........
//example usage
public static void main (String []args){
TabbedPane tab = new TabbedPane();
}
}
Aquí está la clase JPane1:
... JLabel label1 = new JLabel();
label1.setText("This is Tab 1");
jp1.add(label1);
y clase Jpane2 con botón en int
Prueba de JButton = nuevo JButton ("Presione"); jp2.add (prueba);
ButtonHandler phandler = new ButtonHandler();
test.addActionListener(phandler);
setVisible(true);
} entonces el problema está aquí en ActionListener del botón en Jpanel2
class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
// what i do now ? to call jpanel 1 show ![alt text][1]
}
}