How To Create A Java JTabbedPane

The Java JTabbedPane class is usually used by Java programmers to switch between a group of components. The way you switch between components is by clicking on a tab with a given title or even icon.

This class inherits JComponent class because the JComponent class is the base class of all Swing components except top-level containers.

Swing components whose names begin with “J” are descendants of the JComponent class, i.e JButton, JTable etc. Except JFrame and JDialog don’t inherit this JComponent.

Here’s an example for Java JTabbedPane App :

import javax.swing.*;  
 public class TabbedPaneExample {  
 JFrame f;  
     f=new JFrame(); 

JPanel p1=new JPanel();   
JPanel p2=new JPanel();    
JPanel p3=new JPanel();  

JTabbedPane tp=new JTabbedPane();  


 public static void main(String[] args) {  
     new TabbedPaneExample();  

And here’s what you’ll get :

Java JTabbedPane

Now you can switch between “main”, “visit”, “help” components by clicking on its tab title.

Published by

Rafif Santika

The programming language that I specialize in is Java, because I think Java programming language is more universal and of course because I like it regardless of any reason.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.