src/java.desktop/share/classes/javax/swing/UIManager.java

Print this page




  89  * SwingUtilities#updateComponentTreeUI} makes it easy to apply {@code
  90  * updateUI} to a containment hierarchy. Refer to it for
  91  * details. The exact behavior of not invoking {@code
  92  * updateUI} after changing the look and feel is
  93  * unspecified. It is very possible to receive unexpected exceptions,
  94  * painting problems, or worse.
  95  *
  96  * <h3>Default look and feel</h3>
  97  *
  98  * The class used for the default look and feel is chosen in the following
  99  * manner:
 100  * <ol>
 101  *   <li>If the system property <code>swing.defaultlaf</code> is
 102  *       {@code non-null}, use its value as the default look and feel class
 103  *       name.
 104  *   <li>If the {@link java.util.Properties} file <code>swing.properties</code>
 105  *       exists and contains the key <code>swing.defaultlaf</code>,
 106  *       use its value as the default look and feel class name. The location
 107  *       that is checked for <code>swing.properties</code> may vary depending
 108  *       upon the implementation of the Java platform. Typically the
 109  *       <code>swing.properties</code> file is located in the <code>lib</code>
 110  *       subdirectory of the Java installation directory.
 111  *       Refer to the release notes of the implementation being used for
 112  *       further details.
 113  *   <li>Otherwise use the cross platform look and feel.
 114  * </ol>
 115  *
 116  * <h3>Defaults</h3>
 117  *
 118  * {@code UIManager} manages three sets of {@code UIDefaults}. In order, they
 119  * are:
 120  * <ol>
 121  *   <li>Developer defaults. With few exceptions Swing does not
 122  *       alter the developer defaults; these are intended to be modified
 123  *       and used by the developer.
 124  *   <li>Look and feel defaults. The look and feel defaults are
 125  *       supplied by the look and feel at the time it is installed as the
 126  *       current look and feel ({@code setLookAndFeel()} is invoked). The
 127  *       look and feel defaults can be obtained using the {@code
 128  *       getLookAndFeelDefaults()} method.
 129  *   <li>System defaults. The system defaults are provided by Swing.


 264      */
 265 
 266     private static final String defaultLAFKey = "swing.defaultlaf";
 267     private static final String auxiliaryLAFsKey = "swing.auxiliarylaf";
 268     private static final String multiplexingLAFKey = "swing.plaf.multiplexinglaf";
 269     private static final String installedLAFsKey = "swing.installedlafs";
 270     private static final String disableMnemonicKey = "swing.disablenavaids";
 271 
 272     /**
 273      * Return a <code>swing.properties</code> file key for the attribute of specified
 274      * look and feel.  The attr is either "name" or "class", a typical
 275      * key would be: "swing.installedlaf.windows.name"
 276      */
 277     private static String makeInstalledLAFKey(String laf, String attr) {
 278         return "swing.installedlaf." + laf + "." + attr;
 279     }
 280 
 281     /**
 282      * The location of the <code>swing.properties</code> property file is
 283      * implementation-specific.
 284      * It is typically located in the <code>lib</code> subdirectory of the Java
 285      * installation directory. This method returns a bogus filename
 286      * if <code>java.home</code> isn't defined.
 287      */
 288     private static String makeSwingPropertiesFilename() {
 289         String sep = File.separator;
 290         // No need to wrap this in a doPrivileged as it's called from
 291         // a doPrivileged.
 292         String javaHome = System.getProperty("java.home");
 293         if (javaHome == null) {
 294             javaHome = "<java.home undefined>";
 295         }
 296         return javaHome + sep + "lib" + sep + "swing.properties";
 297     }
 298 
 299 
 300     /**
 301      * Provides a little information about an installed
 302      * <code>LookAndFeel</code> for the sake of configuring a menu or
 303      * for initial application set up.
 304      *
 305      * @see UIManager#getInstalledLookAndFeels
 306      * @see LookAndFeel
 307      */
 308     public static class LookAndFeelInfo {
 309         private String name;
 310         private String className;
 311 
 312         /**
 313          * Constructs a <code>UIManager</code>s
 314          * <code>LookAndFeelInfo</code> object.
 315          *
 316          * @param name      a <code>String</code> specifying the name of




  89  * SwingUtilities#updateComponentTreeUI} makes it easy to apply {@code
  90  * updateUI} to a containment hierarchy. Refer to it for
  91  * details. The exact behavior of not invoking {@code
  92  * updateUI} after changing the look and feel is
  93  * unspecified. It is very possible to receive unexpected exceptions,
  94  * painting problems, or worse.
  95  *
  96  * <h3>Default look and feel</h3>
  97  *
  98  * The class used for the default look and feel is chosen in the following
  99  * manner:
 100  * <ol>
 101  *   <li>If the system property <code>swing.defaultlaf</code> is
 102  *       {@code non-null}, use its value as the default look and feel class
 103  *       name.
 104  *   <li>If the {@link java.util.Properties} file <code>swing.properties</code>
 105  *       exists and contains the key <code>swing.defaultlaf</code>,
 106  *       use its value as the default look and feel class name. The location
 107  *       that is checked for <code>swing.properties</code> may vary depending
 108  *       upon the implementation of the Java platform. Typically the
 109  *       <code>swing.properties</code> file is located in the <code>conf</code>
 110  *       subdirectory of the Java installation directory.
 111  *       Refer to the release notes of the implementation being used for
 112  *       further details.
 113  *   <li>Otherwise use the cross platform look and feel.
 114  * </ol>
 115  *
 116  * <h3>Defaults</h3>
 117  *
 118  * {@code UIManager} manages three sets of {@code UIDefaults}. In order, they
 119  * are:
 120  * <ol>
 121  *   <li>Developer defaults. With few exceptions Swing does not
 122  *       alter the developer defaults; these are intended to be modified
 123  *       and used by the developer.
 124  *   <li>Look and feel defaults. The look and feel defaults are
 125  *       supplied by the look and feel at the time it is installed as the
 126  *       current look and feel ({@code setLookAndFeel()} is invoked). The
 127  *       look and feel defaults can be obtained using the {@code
 128  *       getLookAndFeelDefaults()} method.
 129  *   <li>System defaults. The system defaults are provided by Swing.


 264      */
 265 
 266     private static final String defaultLAFKey = "swing.defaultlaf";
 267     private static final String auxiliaryLAFsKey = "swing.auxiliarylaf";
 268     private static final String multiplexingLAFKey = "swing.plaf.multiplexinglaf";
 269     private static final String installedLAFsKey = "swing.installedlafs";
 270     private static final String disableMnemonicKey = "swing.disablenavaids";
 271 
 272     /**
 273      * Return a <code>swing.properties</code> file key for the attribute of specified
 274      * look and feel.  The attr is either "name" or "class", a typical
 275      * key would be: "swing.installedlaf.windows.name"
 276      */
 277     private static String makeInstalledLAFKey(String laf, String attr) {
 278         return "swing.installedlaf." + laf + "." + attr;
 279     }
 280 
 281     /**
 282      * The location of the <code>swing.properties</code> property file is
 283      * implementation-specific.
 284      * It is typically located in the <code>conf</code> subdirectory of the Java
 285      * installation directory. This method returns a bogus filename
 286      * if <code>java.home</code> isn't defined.
 287      */
 288     private static String makeSwingPropertiesFilename() {
 289         String sep = File.separator;
 290         // No need to wrap this in a doPrivileged as it's called from
 291         // a doPrivileged.
 292         String javaHome = System.getProperty("java.home");
 293         if (javaHome == null) {
 294             javaHome = "<java.home undefined>";
 295         }
 296         return javaHome + sep + "conf" + sep + "swing.properties";
 297     }
 298 
 299 
 300     /**
 301      * Provides a little information about an installed
 302      * <code>LookAndFeel</code> for the sake of configuring a menu or
 303      * for initial application set up.
 304      *
 305      * @see UIManager#getInstalledLookAndFeels
 306      * @see LookAndFeel
 307      */
 308     public static class LookAndFeelInfo {
 309         private String name;
 310         private String className;
 311 
 312         /**
 313          * Constructs a <code>UIManager</code>s
 314          * <code>LookAndFeelInfo</code> object.
 315          *
 316          * @param name      a <code>String</code> specifying the name of