Contoh program berikut ini mendemonstrasikan bagaimana membuat panel-panel dalam bentuk Tab di java. Class yang digunakan adalah JTabbedPane.
Berikut ini tampilannya:
Berikut ini contoh programnya:
02 | import java.awt.event.*; |
05 | public class TabbedPaneDemo extends JFrame { |
06 | private JTabbedPane tabPane; |
07 | private JLabel label1, label2, label3; |
08 | private JPanel panel1, panel2, panel3; |
10 | public TabbedPaneDemo () { |
11 | super ( "Tabbed Pane Demo" ); |
13 | tabPane = new JTabbedPane (); |
14 | label1 = new JLabel ( "Panel pertama" , SwingConstants.CENTER); |
15 | panel1 = new JPanel (); |
17 | tabPane.addTab ( "Tab Pertama" , null , panel1, "Panel Pertama" ); |
19 | label2 = new JLabel ( "Panel kedua" , SwingConstants.CENTER); |
20 | panel2 = new JPanel (); |
21 | panel2.setBackground(Color.ORANGE); |
23 | Icon icon = new ImageIcon ( "images/new.gif" ); |
24 | tabPane.addTab ( "Tab Kedua" , icon, panel2, "Panel Kedua" ); |
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); |
35 | tabPane.addTab ( "Tab Ketiga" , null , panel3, "Panel Ketiga" ); |
37 | getContentPane().add(tabPane); |
40 | setLocationRelativeTo ( null ); |
44 | public static void main (String args[]) { |
45 | TabbedPaneDemo test = new TabbedPaneDemo (); |
46 | test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
Semoga bermanfaat
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 berikut ini mendemonstrasikan bagaimana membuat panel-panel dalam bentuk Tab di java. Class yang digunakan adalah JTabbedPane.
Berikut ini tampilannya:
Berikut ini contoh programnya:
02 | import java.awt.event.*; |
05 | public class TabbedPaneDemo extends JFrame { |
06 | private JTabbedPane tabPane; |
07 | private JLabel label1, label2, label3; |
08 | private JPanel panel1, panel2, panel3; |
10 | public TabbedPaneDemo () { |
11 | super ( "Tabbed Pane Demo" ); |
13 | tabPane = new JTabbedPane (); |
14 | label1 = new JLabel ( "Panel pertama" , SwingConstants.CENTER); |
15 | panel1 = new JPanel (); |
17 | tabPane.addTab ( "Tab Pertama" , null , panel1, "Panel Pertama" ); |
19 | label2 = new JLabel ( "Panel kedua" , SwingConstants.CENTER); |
20 | panel2 = new JPanel (); |
21 | panel2.setBackground(Color.ORANGE); |
23 | Icon icon = new ImageIcon ( "images/new.gif" ); |
24 | tabPane.addTab ( "Tab Kedua" , icon, panel2, "Panel Kedua" ); |
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); |
35 | tabPane.addTab ( "Tab Ketiga" , null , panel3, "Panel Ketiga" ); |
37 | getContentPane().add(tabPane); |
40 | setLocationRelativeTo ( null ); |
44 | public static void main (String args[]) { |
45 | TabbedPaneDemo test = new TabbedPaneDemo (); |
46 | test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
Semoga bermanfaat
0 komentar:
Posting Komentar