package com.java.myapp;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
public class MyForm extends JFrame {
private JPanel panel1;
private JPanel panel2;
private JPanel panel3;
private JPanel panel4;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
MyForm frame = new MyForm();
frame.setVisible(true);
}
});
}
/**
* Create the frame.
*/
public MyForm() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 458, 287);
setTitle("ThaiCreate.Com Java GUI Tutorial");
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
getContentPane().add(mainPanel);
itemTabPanel1();
itemTabPanel2();
itemTabPanel3();
itemTabPanel4();
JTabbedPane tabPane = new JTabbedPane();
tabPane.addTab( "Tab 1", panel1);
tabPane.addTab( "Tab 2", panel2);
tabPane.addTab( "Tab 3", panel3);
tabPane.addTab( "Tab 4", panel4);
mainPanel.add(tabPane);
}
public void itemTabPanel1()
{
panel1 = new JPanel();
panel1.setLayout(null);
JButton btn1 = new JButton("Button 1");
btn1.setBounds(10, 11, 89, 23);
panel1.add(btn1);
JButton btn2 = new JButton("Button 2");
btn2.setBounds(10, 45, 89, 23);
panel1.add(btn2);
}
public void itemTabPanel2()
{
panel2 = new JPanel();
panel2.setLayout(null);
JButton btn3 = new JButton("Button 3");
btn3.setBounds(10, 11, 89, 23);
panel2.add(btn3);
JButton btn4 = new JButton("Button 4");
btn4.setBounds(10, 45, 89, 23);
panel2.add(btn4);
}
public void itemTabPanel3()
{
panel3 = new JPanel();
panel3.setLayout(null);;
JButton btn5 = new JButton("Button 5");
btn5.setBounds(10, 11, 89, 23);
panel3.add(btn5);
JButton btn6 = new JButton("Button 6");
btn6.setBounds(10, 45, 89, 23);
panel3.add(btn6);
}
public void itemTabPanel4()
{
panel4 = new JPanel();
panel4.setLayout(null);;
JButton btn7 = new JButton("Button 7");
btn7.setBounds(10, 11, 89, 23);
panel4.add(btn7);
JButton btn8 = new JButton("Button 8");
btn8.setBounds(10, 45, 89, 23);
panel4.add(btn8);
}
}