Alright, I will give you some example code for making a multiple tabs with Swing
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JButton;
public class GUI extends JFrame {
private JTabbedPane tabManager = new JTabbedPane(JTabbedPane.TOP); // This will manage the tabs
// Some GUI code...
public void addTab(String name, JPanel panel) { // Takes in a name for the tab and
// a panel for the tab to display when clicked
getContentPane().add(tabManager);
tabManager.addTab(name, null, panel, name); // The first name is the name of
// the tab and second one is what
// is display in the little popup
// thing when you hover the mouse
// over the tab
}
public void removeTab(int index) { // Removes a tab at the index
tabManager.removeTabAt(index);
}
// Some more GUI code...
public static void main(String[] args) { // In main method or anywhere else
GUI gui = new GUI(/*constructorParams*/);
JPanel panel = new JPanel();
panel.add(new JButton("This is a button!"));
gui.addTab("This is a tab!", panel); // Adds a tab with the name
// "This is a tab!" and the panel to display "panel"
}
}
See this link for more details about the JTabbedPane