Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Tabbed Panel in Swing

  Asked By: Kiswar    Date: Oct 10    Category: Java    Views: 1888
  

Iam trying to write a small program to create a labelfield and a
tabbed panel in Swing.Iam getting errors in the addTab method can
somebody help me?


import javax.swing.* ;
import java.awt.*;
import java.awt.event.*;


public class sScreen extends JApplet
{
public sScreen()
{
Container contentPane = getContentPane();

JPanel panel1 = new JPanel();
panel1.add(new JLabel("Hi M"));

JTabbedPane tabbedPane = new JTabbedPane();

JPanel jpanel1 = new JPanel();
JPanel jpanel2 = new JPanel();
JPanel jpanel3 = new JPanel();
JPanel jpanel4 = new JPanel();
JPanel jpanel5 = new JPanel();
JPanel jpanel6 = new JPanel();

jpanel1.add(new JLabel("This is Student Registeration"));
jpanel2.add(new JLabel("This is Student Accounts"));
jpanel3.add(new JLabel("This is Student Records"));
jpanel4.add(new JLabel("This is Personal Information"));
jpanel5.add(new JLabel("This is Logout"));



tabbedpane.addTab("Registeration", jpanel1);
tabbedpane.addTab("Student Accounts",jpanel2);
tabbedpane.addTab("Student Records",jpanel3);
tabbedpane.addTab("Personal Information",jpanel4);
tabbedpane.addTab("Logout",jpanel5);


contentPane.setLayout(new BorderLayout());
contentPane.add(panel1);
contentPane.add(tabbedpane);
}

public static void main(String[] args)
{
JFrame frame = new JFrame("sScreen");
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});

frame.getContentPane().add(new sScreen(),
BorderLayout.CENTER);

frame.setSize(400, 600);
frame.setVisible(true);
}
}

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Tinku Paliwal     Answered On: Jul 25

hey just write as
tabbedpane.addTab("Registeration", jpanel1);
in tabbedPane method p should be Capital just as
tabbedPane.addTab("Registeration", jpanel1);

 
Didn't find what you were looking for? Find more on Tabbed Panel in Swing Or get search suggestion and latest updates.




Tagged: