Using an ActionListener To move from One JPanel in a JtabbedPane to another JPanel...
in the same JTabbedPane.
Okay so i'm fairly new to java programming and i can't quite figure out how to use an actionlistener on a JButton in one JPanel to move to another JPanel, both in the same JTabbedPane. I can't quite figure it out sadly. I have tried
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == Button1)
{
Panel2.setVisible(true);
}
}
but that doesn't quite work (and by quite i mean it doesn't). I have already created the panel as a global variable. So please if anyone has any suggestions, please do help.
Re: Using an ActionListener To move from One JPanel in a JtabbedPane to another JPane
If you want to change tabbed views, you'll need to call either setSelectedIndex(...) or setSelectedComponent(...) on the JTabbedPane. The API can help you here.