Results 1 to 5 of 5
  1. #1
    lolshooter is offline Member
    Join Date
    Jan 2009
    Posts
    3
    Rep Power
    0

    Default setSelectedIndex (How to move between tabs)

    Hi,

    This is my code:

    class TabbedPane extends JFrame {
    private JTabbedPane tabbedPane;
    private JPanel panel1;
    private JPanel panel2;
    private JPanel panel3;
    private JPanel panel4;
    private JPanel panel5;
    private JButton j1,j2,j3,j4,j5,j6,j7;
    private ImageIcon icon;
    private int index;


    public TabbedPane()
    {
    setTitle( "Airflow - Een Nemo Project" );
    setSize( 1024, 768 );
    setBackground( Color.YELLOW );


    JPanel topPanel = new JPanel();
    topPanel.setLayout( new BorderLayout() );
    getContentPane().add( topPanel );



    // Het maken/toevoegen van de Tabpagina's
    createPage1();
    createPage2();
    createPage3();
    createPage4();


    // Tabpaneel
    tabbedPane = new JTabbedPane();
    tabbedPane.addTab( "Algemene Informatie", panel1 );
    tabbedPane.addTab( "Werking Stofzuiger", panel2 );
    tabbedPane.addTab( "Werking Ventilator", panel3 );
    tabbedPane.addTab( "Over het Project", panel4 );
    topPanel.add( tabbedPane, BorderLayout.CENTER );
    tabbedPane.setSelectedIndex(0);

    }

    This is my problem:

    I have this now And i have 4 panels:
    public void createPage1()
    { panel1= new JPanel();
    panel1.setLayout( null ); // Layout Kiezen
    panel1.validate()

    j2= new JButton ( " Next" );
    panel1.add( j2 );
    j2.setBounds( 650, 600, 200, 20);

    j6= new JButton ( " Reset " );
    panel1.add( j6 );
    j6.setBounds( 850, 600, 100, 20);

    }

    I want to have the j6 button rest to the first page.
    and the next button to go to to the next page.

    How should my code be?


    Thx :)

  2. #2
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    You opened a new thread, maybe an error. You should have use "Reply" button. Anyway you didn't follow my suggestion to wrap your code inside CODE tags. Select your indented code, then click on the "#". Then "Preview Post" and FINALLY "Submit Reply".

    Help us to help you

  3. #3
    lolshooter is offline Member
    Join Date
    Jan 2009
    Posts
    3
    Rep Power
    0

    Default

    ok the repost here, but this is a other problem, fixed the other one already :).
    class TabbedPane extends JFrame {
    private JTabbedPane tabbedPane;
    private JPanel panel1;
    private JPanel panel2;
    private JPanel panel3;
    private JPanel panel4;
    private JPanel panel5;
    private JButton j1,j2,j3,j4,j5,j6,j7;
    private ImageIcon icon;
    private int index;


    public TabbedPane()
    {
    setTitle( "Airflow - Een Nemo Project" );
    setSize( 1024, 768 );
    setBackground( Color.YELLOW );


    JPanel topPanel = new JPanel();
    topPanel.setLayout( new BorderLayout() );
    getContentPane().add( topPanel );



    // Het maken/toevoegen van de Tabpagina's
    createPage1();
    createPage2();
    createPage3();
    createPage4();


    // Tabpaneel
    tabbedPane = new JTabbedPane();
    tabbedPane.addTab( "Algemene Informatie", panel1 );
    tabbedPane.addTab( "Werking Stofzuiger", panel2 );
    tabbedPane.addTab( "Werking Ventilator", panel3 );
    tabbedPane.addTab( "Over het Project", panel4 );
    topPanel.add( tabbedPane, BorderLayout.CENTER );
    tabbedPane.setSelectedIndex(0);

    }

    This is my problem:

    I have this now And i have 4 panels:
    public void createPage1()
    { panel1= new JPanel();
    panel1.setLayout( null ); // Layout Kiezen
    panel1.validate()

    j2= new JButton ( " Next" );
    panel1.add( j2 );
    j2.setBounds( 650, 600, 200, 20);

    j6= new JButton ( " Reset " );
    panel1.add( j6 );
    j6.setBounds( 850, 600, 100, 20);

    }

  4. #4
    issamsteit is offline Member
    Join Date
    Feb 2010
    Posts
    1
    Rep Power
    0

    Default

    hi ,
    i have somme probleme with tab Pane and i hope that you can help me so,
    i use joomla 1.5 an comunity builder
    in the tab of profiler of any user when i navigate in the differente tab there is no probleme but when i refresh a page i got the first tab for exemple i have tab1: profile tab2 : information tab 3: transaction , and i click in transaction tab i dont have any probleme i get all information in this tab but when i refresh a page i will have the first tab (tab 1 : profile) i cant resolve this probleme and i dont have any idee why they do that

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Hello issamsteit and welcome to the forum. I ask that you please ask any new questions of your own in your own thread rather than hijack an existing thread. Also, please be sure that you're talking about java and not JavaScript (I'm not sure based on your question), and consider posting code with code tags (see my signature). Best of luck!

Similar Threads

  1. Help with Move Shape
    By romina in forum AWT / Swing
    Replies: 2
    Last Post: 12-09-2010, 03:25 AM
  2. Tabs Won't Work In Right Aligned JPanel
    By davidedwardgill in forum AWT / Swing
    Replies: 0
    Last Post: 08-08-2008, 07:45 PM
  3. Replies: 0
    Last Post: 07-07-2008, 04:43 PM
  4. Adding Tabs to JTabbedPane
    By blackstone in forum AWT / Swing
    Replies: 2
    Last Post: 11-14-2007, 03:15 PM
  5. resize tabs in jtabbedpane
    By osval in forum New To Java
    Replies: 1
    Last Post: 08-02-2007, 03:02 AM

Posting Permissions

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