Look and Feel


Anda mungkin kurang suka dengan tampilan default dari komponen swing di java. Sebenarnya anda dapat mengganti tampilan tersebut dengan cara melakukan setting look and feel. Ini adalah contoh perbandingan, dua buah gui dengan menggunakan LAF yang berbeda:

laf1 my software

Gambar sebelah kiri merupakan gui dengan look and feel default, sedangkan gambar sebelah kanan merupakan gui dengan look and feel native. Untuk melakukan perubahan look and feel tambahkan kode berikut:

public static void main(String args[]) {
        try{
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }catch(Exception e){
            System.out.println("error");
        }
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Home().setVisible(true);
            }
        });
    }

Berikut ini adalah contoh lainnya:

try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch(Exception e) {
      System.out.println("Error setting native LAF: " + e);
    }
...
try {
      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch(Exception e) {
      System.out.println("Error setting Java LAF: " + e);
    }
...
try {
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
    } catch(Exception e) {
      System.out.println("Error setting Motif LAF: " + e);
    }

About windupurnomo

I'm interested in programming. I am active with several programming such as Java, C #, C, JavaScript, HTML. I'm also develop desktop application (Java Swing), Mobile Application (Android), and Web programming (ASP MVC).
This entry was posted in Java, Netbeans, programming and tagged , , . Bookmark the permalink.

2 Responses to Look and Feel

  1. aadunjuve says:

    wah rajin ni si Windu, perkembangan hits-nya pun tinggi…

  2. Shems says:

    Gambarnya mana ya kang..?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s