1 package org.columba.core.gui.themes.plugin; 17 18 import java.awt.Dimension ; 19 import java.util.List ; 20 21 import org.columba.core.config.Config; 22 import org.columba.core.xml.XmlElement; 23 24 import com.jgoodies.looks.LookUtils; 25 import com.jgoodies.looks.Options; 26 import com.jgoodies.looks.plastic.PlasticLookAndFeel; 27 import com.jgoodies.looks.plastic.PlasticTheme; 28 import com.jgoodies.looks.plastic.PlasticXPLookAndFeel; 29 30 34 public class PlasticLookAndFeelPlugin extends AbstractThemePlugin { 35 38 public PlasticLookAndFeelPlugin() { 39 super(); 40 } 41 42 45 public void setLookAndFeel() throws Exception { 46 47 Options.setDefaultIconSize(new Dimension (16, 16)); 48 Options.setUseNarrowButtons(false); 49 Options.setPopupDropShadowEnabled(true); 50 51 XmlElement options = Config.getInstance().get("options").getElement( 52 "/options"); 53 XmlElement gui = options.getElement("gui"); 54 XmlElement themeElement = gui.getElement("theme"); 55 56 try { 57 String theme = themeElement.getAttribute("theme"); 59 60 if (theme != null) { 61 PlasticTheme t = getTheme(theme); 62 LookUtils.setLookAndTheme(new PlasticXPLookAndFeel(), t); 63 } else { 64 PlasticTheme t = PlasticLookAndFeel.createMyDefaultTheme(); 65 LookUtils.setLookAndTheme(new PlasticXPLookAndFeel(), t); 66 } 67 68 } catch (Exception e) { 69 System.err.println("Can't set look & feel:" + e); 70 } 71 72 ; 73 } 74 75 protected PlasticTheme[] computeThemes() { 76 List themes = PlasticLookAndFeel.getInstalledThemes(); 77 78 return (PlasticTheme[]) themes.toArray(new PlasticTheme[themes.size()]); 79 } 80 81 protected PlasticTheme getTheme(String name) { 82 PlasticTheme[] themes = computeThemes(); 83 84 for (int i = 0; i < themes.length; i++) { 85 String str = themes[i].getName(); 86 87 if (name.equals(str)) { 88 return themes[i]; 89 } 90 } 91 92 return null; 93 } 94 } 95 | Popular Tags |