Contoh Program Tabbed Panel di Java

Minggu, 15 Januari 2012

Contoh program berikut ini mendemonstrasikan bagaimana membuat panel-panel dalam bentuk Tab di java. Class yang digunakan adalah JTabbedPane.
Berikut ini tampilannya:
contoh-program-tabbed-java

Berikut ini contoh programnya:
01import java.awt.*;
02import java.awt.event.*;
03import javax.swing.*;
04 
05public class TabbedPaneDemo extends JFrame {
06    private JTabbedPane tabPane;
07    private JLabel label1, label2, label3;
08    private JPanel panel1, panel2, panel3;
09 
10    public TabbedPaneDemo () {
11        super ("Tabbed Pane Demo");
12 
13        tabPane = new JTabbedPane ();
14        label1 = new JLabel ("Panel pertama", SwingConstants.CENTER);
15        panel1 = new JPanel ();
16        panel1.add(label1);
17        tabPane.addTab ("Tab Pertama", null, panel1, "Panel Pertama");         
18 
19        label2 = new JLabel ("Panel kedua", SwingConstants.CENTER);
20        panel2 = new JPanel ();
21        panel2.setBackground(Color.ORANGE);
22        panel2.add(label2);
23        Icon icon = new ImageIcon ("images/new.gif");
24        tabPane.addTab ("Tab Kedua", icon, panel2, "Panel Kedua");     
25 
26        label3 = new JLabel ("Panel ketiga", SwingConstants.CENTER);
27        panel3 = new JPanel ();
28        panel3.setBackground(Color.YELLOW);
29        panel3.setLayout(new BorderLayout());
30        panel3.add(new JButton ("North"), BorderLayout.NORTH);
31        panel3.add(new JButton ("West"),  BorderLayout.WEST);
32        panel3.add(new JButton ("East"),  BorderLayout.EAST);
33        panel3.add(new JButton ("South"), BorderLayout.SOUTH);
34        panel3.add(label3);
35        tabPane.addTab ("Tab Ketiga", null, panel3, "Panel Ketiga");   
36 
37        getContentPane().add(tabPane);     
38 
39        setSize (400,300);
40        setLocationRelativeTo (null);
41        setVisible (true);
42    }  
43 
44    public static void main (String args[]) {
45        TabbedPaneDemo test = new TabbedPaneDemo ();
46        test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
47    }
48}
Semoga bermanfaat

0 komentar:

Posting Komentar

Lagu Daerah Bengkulu Selatan

http://www.ziddu.com/download/17765598/PantaiPasarBawah.mp3.html
http://www.ziddu.com/download/17770609/Ading.mp3.html
http://www.ziddu.com/download/17770638/BatinLingiran.mp3.html
http://www.ziddu.com/download/17770712/BeghasKedurang.mp3.html
http://www.ziddu.com/download/17765528/MutighKupi.mp3.html
http://www.ziddu.com/download/17765460/KasiahSayang.mp3.html
http://www.ziddu.com/download/17765364/KemaneAgi.mp3.html
http://www.ziddu.com/download/17765259/KebilauBaliak.mp3.html
http://www.ziddu.com/download/17765180/KedurangBadakuDillahirka.mp3.html
http://www.ziddu.com/download/17764830/TukangKundai.mp3.html
http://www.ziddu.com/download/17764761/SukatanMatau.mp3.html
http://www.ziddu.com/download/17764705/Sinjang.mp3.html
http://www.ziddu.com/download/17764641/Seginim.mp3.html
http://www.ziddu.com/download/17764579/sekundangsetungguan.mp3.html

sumber: Radio Artha FM Bengkulu Selatan

Contoh Program Tabbed Panel di Java


Contoh program berikut ini mendemonstrasikan bagaimana membuat panel-panel dalam bentuk Tab di java. Class yang digunakan adalah JTabbedPane.
Berikut ini tampilannya:
contoh-program-tabbed-java

Berikut ini contoh programnya:
01import java.awt.*;
02import java.awt.event.*;
03import javax.swing.*;
04 
05public class TabbedPaneDemo extends JFrame {
06    private JTabbedPane tabPane;
07    private JLabel label1, label2, label3;
08    private JPanel panel1, panel2, panel3;
09 
10    public TabbedPaneDemo () {
11        super ("Tabbed Pane Demo");
12 
13        tabPane = new JTabbedPane ();
14        label1 = new JLabel ("Panel pertama", SwingConstants.CENTER);
15        panel1 = new JPanel ();
16        panel1.add(label1);
17        tabPane.addTab ("Tab Pertama", null, panel1, "Panel Pertama");         
18 
19        label2 = new JLabel ("Panel kedua", SwingConstants.CENTER);
20        panel2 = new JPanel ();
21        panel2.setBackground(Color.ORANGE);
22        panel2.add(label2);
23        Icon icon = new ImageIcon ("images/new.gif");
24        tabPane.addTab ("Tab Kedua", icon, panel2, "Panel Kedua");     
25 
26        label3 = new JLabel ("Panel ketiga", SwingConstants.CENTER);
27        panel3 = new JPanel ();
28        panel3.setBackground(Color.YELLOW);
29        panel3.setLayout(new BorderLayout());
30        panel3.add(new JButton ("North"), BorderLayout.NORTH);
31        panel3.add(new JButton ("West"),  BorderLayout.WEST);
32        panel3.add(new JButton ("East"),  BorderLayout.EAST);
33        panel3.add(new JButton ("South"), BorderLayout.SOUTH);
34        panel3.add(label3);
35        tabPane.addTab ("Tab Ketiga", null, panel3, "Panel Ketiga");   
36 
37        getContentPane().add(tabPane);     
38 
39        setSize (400,300);
40        setLocationRelativeTo (null);
41        setVisible (true);
42    }  
43 
44    public static void main (String args[]) {
45        TabbedPaneDemo test = new TabbedPaneDemo ();
46        test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
47    }
48}
Semoga bermanfaat