Click here to Skip to main content
14,029,616 members
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 17 Apr 2002
Licenced CPOL

Tab Control in Java ( in AWT)

, 7 Jun 2010
Rate this:
Please Sign up or sign in to vote.
This is a Java tab Control like SS Tab in VB. Its Cool One

Sample Image - tabcontrol.gif


Dear friends, this is one of most useful components in the Java programming world. Here, I am using the Card Layout for developing this component. Download the project files and run the run.bat file to get the output.


The Following files are used in the Tab Control.

  •,, are used to create a customized scroll bar.
  • is used to embed a customized scroll bar into a Panel.
  • is used to create tabs.
  • is the main applet

Source Code

Here is the source code for setting a Tab Panel:

import java.awt.Panel;
import java.awt.CardLayout;
import java.awt.BorderLayout;
import java.awt.*;
import java.awt.event.*;

public class TapPanel extends Panel
    TabPanel(chatClient1 app)
        // Initialize the Components
        chatclient = app;	
        // Main Panel
        RightPanel = new CPanel(300, 500);

        Panel panel2 = new Panel();
        CardLayout cardlayout = new CardLayout();
        UserPanel = new Panel();	  
        UserPanel.add("Center",new Label("User"));

        ImgScrollPanel = new Panel();
        ImgScrollPanel.setLayout(new BorderLayout());

        BuddyPanel = new Panel();
        BuddyPanel.setLayout(new BorderLayout());

        RoomPanel = new Panel();
        RoomPanel.setLayout(new BorderLayout());
        panel2.add("UserPanel", UserPanel);
        panel2.add("RoomPanel", RoomPanel); 
        panel2.add("ImgScrollPanel", ImgScrollPanel); 
        panel2.add("BuddyPanel", BuddyPanel);, "UserPanel");

        RightTab = new BorderPanel(this,chatclient, cardlayout, panel2, 210, 270);

        RightTab.addTab("USERS", "UserPanel");
        RightTab.addTab("ROOMS", "RoomPanel"); 
        RightTab.addTab("IMAGES", "ImgScrollPanel");
        RightTab.addTab("BUDDY", "BuddyPanel");

    Panel LeftPanel, BuddyPanel, RoomPanel, ImgScrollPanel, UserPanel;
    CPanel RightPanel;
    BorderPanel RightTab;
    chatClient1 chatclient;
    public int i;


If you want a TabPanel, you can import the TabPanel class in your applet or main application. Adding the code tab = new TabPanel(this); will embed it into your application.

Jeeva S


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Jeeva S
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

Questionفين باقى الكود بتاع الشات والmain function ?? Pin
Fatomaa 30-Aug-12 18:36
memberFatomaa 30-Aug-12 18:36 
Questionneed help Pin
Attaullah bablu30-Nov-11 6:53
memberAttaullah bablu30-Nov-11 6:53 
QuestionNeed your Assistance Pin
Niraj Deshmukh12313-Nov-11 22:18
memberNiraj Deshmukh12313-Nov-11 22:18 
GeneralCode java of Chat program Pin
thopt3-Nov-09 7:51
memberthopt3-Nov-09 7:51 
GeneralNew in Java [modified] Pin
askPrins17-Jul-08 9:30
memberaskPrins17-Jul-08 9:30 
GeneralHey! Pin
138256ssn16-Sep-07 8:03
member138256ssn16-Sep-07 8:03 
GeneralRe: Hey! Pin
askPrins17-Jul-08 9:11
memberaskPrins17-Jul-08 9:11 
General*-- How to GET the SOURCE CODE -- * Pin
theo25121-Feb-07 1:35
membertheo25121-Feb-07 1:35 
Generalhave the coding Pin
coool_ajit17-Apr-06 19:44
membercoool_ajit17-Apr-06 19:44 
Generalplz send Pin
ashishkumar.er20-Mar-06 5:59
memberashishkumar.er20-Mar-06 5:59 
GeneralThere is an error in your run.bat file Pin
code rider17-Oct-04 19:30
membercode rider17-Oct-04 19:30 
QuestionNo Source files!? Pin
T.Haberkern19-Apr-02 0:39
memberT.Haberkern19-Apr-02 0:39 
AnswerRe: No Source files!? Pin
tedyoung2-Dec-03 10:36
membertedyoung2-Dec-03 10:36 
Answer Pin
Shawn Liu12-Oct-04 18:47
memberShawn Liu12-Oct-04 18:47 
GeneralRe: Pin
ksnare29-May-08 5:41
memberksnare29-May-08 5:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190419.4 | Last Updated 7 Jun 2010
Article Copyright 2002 by Jeeva S
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid