Help with JTabbedPane..

I've read the tutorials lots, but to no avail, I need help with make it so when you click a tab it actually changes, here take a look at thisprivatestaticvoid createTabbedPane(){

tabBox =new JTabbedPane();

tabBox.addTab("User Stuff", userPanel);

tabBox.addTab("Initialization", passPanel);

}

Do i need a Listener to change tabs with a click of the mouse?

[631 byte] By [Shadow1222a] at [2007-11-27 3:16:56]
# 1
How about a 20-line complete program that illustrates your issue. What are we supposed to do with this one method?
kirillga at 2007-7-12 8:19:31 > top of Java-index,Desktop,Core GUI APIs...
# 2

you don't need a mouselistener...

import java.awt.Dimension;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JTabbedPane;

public class MyTabbedPane extends JFrame {

private static JTabbedPane tabBox;

private static JPanel userPanel;

private static JPanel passPanel;

public MyTabbedPane() {

createUserPanel();

createPassPanel();

createTabbedPane();

add(tabBox);

}

private static void createUserPanel() {

userPanel = new JPanel();

// just for demonstrating i add a label here

JLabel label = new JLabel("userPanel");

userPanel.add(label);

}

private static void createPassPanel() {

passPanel = new JPanel();

//just for demonstrating i add a label here

JLabel label = new JLabel("passLabel");

passPanel.add(label);

}

private static void createTabbedPane() {

tabBox = new JTabbedPane();

tabBox.addTab("User Stuff", userPanel);

tabBox.addTab("Initialization", passPanel);

}

/**

* Create the GUI and show it.

*/

private static void createAndShowGUI() {

// Create and set up the window.

JFrame frame = new JFrame();

frame = new MyTabbedPane();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setTitle("MyTabbedPane");

frame.setPreferredSize(new Dimension(300, 300));

// Display the window.

frame.pack();

frame.setVisible(true);

}

public static void main(String[] args) {

// Schedule a job for the event-dispatching thread:

// creating and showing this application's GUI.

javax.swing.SwingUtilities.invokeLater(new Runnable() {

public void run() {

createAndShowGUI();

}

});

}

}

izziieea at 2007-7-12 8:19:31 > top of Java-index,Desktop,Core GUI APIs...