Tampilan frame atau lebih dikenal dengan “Look and Feel” di java dapat diatur sesuai keinginan kita. Java memiliki 3 Look and Feel dasar yaitu Metal, Motif dan Windows. Selain itu banyak tersedia
Look and Feel di internet yang dapat didownload secara gratis. Berikut ini contoh program yang mengatur tampilan atau tema dan frame.
Dan berikut ini contoh tampilannya:
Berikut ini program lengkapnya:
003 | import java.awt.event.*; |
007 | public class LookAndFeelDemo extends JFrame { |
009 | private final String lookName[] = { "Metal" , "Motif" , "Windows" }; |
011 | private UIManager.LookAndFeelInfo looks[]; |
013 | private JRadioButton rdLook[]; |
015 | private ButtonGroup btnGroup; |
019 | private JTextField txt; |
021 | private JPanel panel1, panel2; |
023 | public LookAndFeelDemo () { |
025 | super ( "Look and Feel Demo : Tampilan Frame" ); |
029 | Container container = getContentPane(); |
031 | ItemHandler handler = new ItemHandler (); |
033 | panel1 = new JPanel(); |
035 | panel2 = new JPanel(); |
037 | btnGroup = new ButtonGroup(); |
039 | rdLook = new JRadioButton [lookName.length]; |
041 | for ( int i = 0 ; i < rdLook.length; i++) { |
043 | rdLook[i] = new JRadioButton (lookName[i]); |
045 | rdLook[i].addItemListener(handler); |
047 | btnGroup.add(rdLook[i]); |
049 | panel2.add(rdLook[i]); |
053 | btn = new JButton ( "Tombol" ); |
055 | txt = new JTextField ( 20 ); |
061 | container.add(panel1, BorderLayout.NORTH); |
063 | container.add(panel2, BorderLayout.SOUTH); |
065 | looks = UIManager.getInstalledLookAndFeels(); |
067 | setLocationRelativeTo ( null ); |
073 | private void changeLookAndFeel( int val) { |
077 | UIManager.setLookAndFeel(looks[val].getClassName()); |
079 | SwingUtilities.updateComponentTreeUI( this ); |
083 | catch (Exception ex) { |
085 | ex.printStackTrace(); |
091 | public static void main (String args[]) { |
093 | LookAndFeelDemo test = new LookAndFeelDemo(); |
095 | test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
099 | private class ItemHandler implements ItemListener { |
101 | public void itemStateChanged (ItemEvent e) { |
105 | for ( int i = 0 ; i < rdLook.length; i++) { |
107 | if (rdLook[i].isSelected()) { |
109 | changeLookAndFeel (i); |
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
Tampilan frame atau lebih dikenal dengan “Look and Feel” di java dapat diatur sesuai keinginan kita. Java memiliki 3 Look and Feel dasar yaitu Metal, Motif dan Windows. Selain itu banyak tersedia
Look and Feel di internet yang dapat didownload secara gratis. Berikut ini contoh program yang mengatur tampilan atau tema dan frame.
Dan berikut ini contoh tampilannya:
Berikut ini program lengkapnya:
003 | import java.awt.event.*; |
007 | public class LookAndFeelDemo extends JFrame { |
009 | private final String lookName[] = { "Metal" , "Motif" , "Windows" }; |
011 | private UIManager.LookAndFeelInfo looks[]; |
013 | private JRadioButton rdLook[]; |
015 | private ButtonGroup btnGroup; |
019 | private JTextField txt; |
021 | private JPanel panel1, panel2; |
023 | public LookAndFeelDemo () { |
025 | super ( "Look and Feel Demo : Tampilan Frame" ); |
029 | Container container = getContentPane(); |
031 | ItemHandler handler = new ItemHandler (); |
033 | panel1 = new JPanel(); |
035 | panel2 = new JPanel(); |
037 | btnGroup = new ButtonGroup(); |
039 | rdLook = new JRadioButton [lookName.length]; |
041 | for ( int i = 0 ; i < rdLook.length; i++) { |
043 | rdLook[i] = new JRadioButton (lookName[i]); |
045 | rdLook[i].addItemListener(handler); |
047 | btnGroup.add(rdLook[i]); |
049 | panel2.add(rdLook[i]); |
053 | btn = new JButton ( "Tombol" ); |
055 | txt = new JTextField ( 20 ); |
061 | container.add(panel1, BorderLayout.NORTH); |
063 | container.add(panel2, BorderLayout.SOUTH); |
065 | looks = UIManager.getInstalledLookAndFeels(); |
067 | setLocationRelativeTo ( null ); |
073 | private void changeLookAndFeel( int val) { |
077 | UIManager.setLookAndFeel(looks[val].getClassName()); |
079 | SwingUtilities.updateComponentTreeUI( this ); |
083 | catch (Exception ex) { |
085 | ex.printStackTrace(); |
091 | public static void main (String args[]) { |
093 | LookAndFeelDemo test = new LookAndFeelDemo(); |
095 | test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
099 | private class ItemHandler implements ItemListener { |
101 | public void itemStateChanged (ItemEvent e) { |
105 | for ( int i = 0 ; i < rdLook.length; i++) { |
107 | if (rdLook[i].isSelected()) { |
109 | changeLookAndFeel (i); |
Semoga bermanfaat.
0 komentar:
Posting Komentar