KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > wizard > LnFListener


1 package org.webdocwf.util.loader.wizard;
2
3 import java.awt.*;
4 import java.awt.event.*;
5 import javax.swing.*;
6
7 public class LnFListener implements ActionListener {
8   JFrame frame;
9
10   public LnFListener(JFrame f) {
11     frame = f;
12   }
13
14   public void actionPerformed(ActionEvent e) {
15     String JavaDoc lnfName = null;
16     if (e.getActionCommand().equals("Java Look&Feel")) {
17       lnfName = UIManager.getCrossPlatformLookAndFeelClassName();
18     } else if (e.getActionCommand().equals("Metal Look&Feel")) {
19       lnfName = "javax.swing.plaf.metal.MetalLookAndFeel";
20     } else if (e.getActionCommand().equals("Motif Look&Feel")) {
21       lnfName = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
22     } else if (e.getActionCommand().equals("Windows Look&Feel")) {
23       lnfName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
24     } else {
25       System.err.println("Unrecognized L&F request action: " +
26         e.getActionCommand());
27       return;
28     }
29     try {
30       UIManager.setLookAndFeel(lnfName);
31       SwingUtilities.updateComponentTreeUI(frame);
32     }
33     catch (UnsupportedLookAndFeelException ex1) {
34       System.err.println("Unsupported LookAndFeel: " + lnfName);
35     }
36     catch (ClassNotFoundException JavaDoc ex2) {
37       System.err.println("LookAndFeel class not found: " + lnfName);
38     }
39     catch (InstantiationException JavaDoc ex3) {
40       System.err.println("Could not load LookAndFeel: " + lnfName);
41     }
42     catch (IllegalAccessException JavaDoc ex4) {
43       System.err.println("Cannot use LookAndFeel: " + lnfName);
44     }
45   }
46 }
47
Popular Tags