Results 1 to 2 of 2
  1. #1
    Ermm is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default 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.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default 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.

Similar Threads

  1. Replies: 4
    Last Post: 04-19-2011, 06:09 AM
  2. Replies: 2
    Last Post: 12-19-2010, 03:24 PM
  3. Using Jscrollpane to move images on jpanel
    By Lazairus in forum New To Java
    Replies: 0
    Last Post: 12-06-2010, 03:46 PM
  4. Move Jpanel to center
    By tpyq in forum NetBeans
    Replies: 1
    Last Post: 12-15-2008, 11:11 AM
  5. Replies: 2
    Last Post: 12-01-2007, 08:48 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •