Hi friend,
import javax.swing.*;
import java.awt.*;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
public class VariousComponent extends JFrame{
public VariousComponent(){
super("This is simple button form");
JPanel panel = new JPanel();
getContentPane().add(panel, java.awt.BorderLayout.NORTH);
JButton button=new JButton("Ok");
button.setSize(20,20);
panel.add(button);
ImageIcon icon = new ImageIcon();
JTabbedPane tabbedPane = new JTabbedPane();
Component panel1 = makeTextPanel("Java Tutorial");
tabbedPane.addTab("One", icon, panel1, "Does nothing");
tabbedPane.setSelectedIndex(0);
Component panel2 = makeTextPanel("Java, JavaScript,JSP");
tabbedPane.addTab("Two", icon, panel2, "Does twice as much nothing");
Component panel3 = makeTextPanel("Java, Servlet JSP Struts2.0 ");
tabbedPane.addTab("Three", icon, panel3, "Still something else");
Component panel4 = makeTextPanel("Java, Servlet JSP Struts2.0 HTML ");
tabbedPane.addTab("Four", icon, panel4, "Now click get more title");
//Add the tabbed pane to this panel.
setLayout(new GridLayout(1, 1));
add(tabbedPane);
}
private Component makeTextPanel(String text) {
JPanel panel = new JPanel(false);
JLabel lable = new JLabel(text);
lable.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(lable);
return panel;
}
public static void main(String args[]){
System.out.println("Simple button example.");
VariousComponent comp = new VariousComponent();
comp.setVisible(true);
comp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
comp.setSize(500,400);
}
}
-----------------------------------------------------
Read for more information.
http://www.roseindia.net/java/