javacodex.com
Java Examples
Java Examples
memu home questions

JTabbedPane

Sometimes, because of space limitation, it is not possible to display all pieces of information in a window. You can group and separate pieces of information in a window using a JTabbedPane.

Source: (JTabbedPaneExample.java)

import javax.swing.*;
import java.awt.*;
 
public class JTabbedPaneExample {
  public static void main(String [] args) {
 
    JFrame frame = new JFrame("JTabbedPane Example");
    frame.setSize(300,200);
 
    JTabbedPane tabs = new JTabbedPane();		 
    tabs.add("Tab 1", new JLabel("TAB 1 - CONTENT"));
    tabs.add("Tab 2", new JLabel("TAB 2 - CONTENT"));
 
    frame.add(tabs);	
    frame.setVisible(true);			
  }
}
 

Output:

$ java JTabbedPaneExample
Output



Contact: javacodex@yahoo.com