1 18 19 package org.apache.jmeter.gui.action; 20 21 import java.awt.event.ActionEvent ; 22 import java.util.HashSet ; 23 import java.util.Set ; 24 25 import javax.swing.SwingUtilities ; 26 import javax.swing.UIManager ; 27 28 import org.apache.jmeter.gui.GuiPackage; 29 import org.apache.jmeter.util.JMeterUtils; 30 31 35 public class LookAndFeelCommand implements Command 36 { 37 38 private static Set commands = new HashSet (); 39 static { 40 UIManager.LookAndFeelInfo [] lfs = UIManager.getInstalledLookAndFeels(); 41 for (int i = 0; i < lfs.length; i++) 42 { 43 commands.add("laf:" + lfs[i].getClassName()); 44 } 45 46 try 47 { 48 String defaultUI = 49 JMeterUtils.getPropDefault( 50 "jmeter.laf", 51 UIManager.getCrossPlatformLookAndFeelClassName()); 52 UIManager.setLookAndFeel(defaultUI); 53 } 54 catch (Exception e) 55 { 56 } 57 } 58 59 public LookAndFeelCommand() 60 { 61 } 62 63 public void doAction(ActionEvent ev) 64 { 65 try 66 { 67 String className = 68 ev.getActionCommand().substring(4).replace('/', '.'); 69 UIManager.setLookAndFeel(className); 70 SwingUtilities.updateComponentTreeUI( 71 GuiPackage.getInstance().getMainFrame()); 72 } 73 catch (javax.swing.UnsupportedLookAndFeelException e) 74 { 75 JMeterUtils.reportErrorToUser( 76 "Look and Feel unavailable:" + e.toString()); 77 } 78 catch (InstantiationException e) 79 { 80 JMeterUtils.reportErrorToUser( 81 "Look and Feel unavailable:" + e.toString()); 82 } 83 catch (ClassNotFoundException e) 84 { 85 JMeterUtils.reportErrorToUser( 86 "Look and Feel unavailable:" + e.toString()); 87 } 88 catch (IllegalAccessException e) 89 { 90 JMeterUtils.reportErrorToUser( 91 "Look and Feel unavailable:" + e.toString()); 92 } 93 } 94 95 public Set getActionNames() 96 { 97 return commands; 98 } 99 } 100 | Popular Tags |