jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html
changeset 25859 3317bb8137f4
parent 23010 6dadb192ad81
child 38388 84ab1f133f16
equal deleted inserted replaced
25858:836adbf7a2cd 25859:3317bb8137f4
       
     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
       
     2 <html>
       
     3 <head>
       
     4 <!--
       
     5 Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
       
     6 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     7 
       
     8 This code is free software; you can redistribute it and/or modify it
       
     9 under the terms of the GNU General Public License version 2 only, as
       
    10 published by the Free Software Foundation.  Oracle designates this
       
    11 particular file as subject to the "Classpath" exception as provided
       
    12 by Oracle in the LICENSE file that accompanied this code.
       
    13 
       
    14 This code is distributed in the hope that it will be useful, but WITHOUT
       
    15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    16 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    17 version 2 for more details (a copy is included in the LICENSE file that
       
    18 accompanied this code).
       
    19 
       
    20 You should have received a copy of the GNU General Public License version
       
    21 2 along with this work; if not, write to the Free Software Foundation,
       
    22 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    23 
       
    24 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    25 or visit www.oracle.com if you need additional information or have any
       
    26 questions.
       
    27 -->
       
    28 <title></title>
       
    29 </head>
       
    30 <body bgcolor="white">
       
    31 
       
    32 Provides user interface objects built according to the cross-platform
       
    33 Nimbus look and feel.
       
    34 
       
    35 <p>Nimbus uses instances of the {@link javax.swing.Painter} interface to paint
       
    36 components. With each Swing component it associates a foreground and a
       
    37 background {@code Painter}, and there may be several painters for different
       
    38 component states.
       
    39 
       
    40 <p>Nimbus allows customizing many of its properties, including painters, by
       
    41 altering the {@link javax.swing.UIDefaults} table. Here's an example:
       
    42 <pre>
       
    43     UIManager.put("ProgressBar.tileWidth", myTileWidth);
       
    44     UIManager.put("ProgressBar[Enabled].backgroundPainter", myBgPainter);
       
    45     UIManager.put("ProgressBar[Enabled].foregroundPainter", myFgPainter);
       
    46 </pre>
       
    47 
       
    48 <p>Per-component customization is also possible. When rendering a component,
       
    49 Nimbus checks its client property named "Nimbus.Overrides". The value of this
       
    50 property should be an instance of {@code UIDefaults}. Settings from that table
       
    51 override the UIManager settings, but for that particular component instance
       
    52 only. An optional client property, "Nimbus.Overrides.InheritDefaults" of type
       
    53 Boolean, specifies whether the overriding settings should be merged with
       
    54 default ones ({@code true}), or replace them ({@code false}). By default they
       
    55 are merged:
       
    56 <pre>
       
    57     JProgressBar bar = new JProgressBar();
       
    58     UIDefaults overrides = new UIDefaults();
       
    59     overrides.put("ProgressBar.cycleTime", 330);
       
    60     ...
       
    61     bar.putClientProperty("Nimbus.Overrides", overrides);
       
    62     bar.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
       
    63 </pre>
       
    64 
       
    65 <p>Colors in Nimbus are derived from a core set of
       
    66 <a href="doc-files/properties.html#primaryColors">primary colors</a>. There are also
       
    67 <a href="doc-files/properties.html#secondaryColors">secondary colors</a>, which are
       
    68 derived from primary ones, but serve themselves as base colors for other
       
    69 derived colors. The derivation mechanism allows for runtime customization,
       
    70 i.e. if a primary or secondary color is changed, all colors that are derived
       
    71 from it are automatically updated. The method
       
    72 {@link javax.swing.plaf.nimbus.NimbusLookAndFeel#getDerivedColor(java.lang.String, float, float, float, int, boolean)}
       
    73 may be used to create a derived color.
       
    74 
       
    75 <p>These classes are designed to be used while the
       
    76 corresponding <code>LookAndFeel</code> class has been
       
    77 installed
       
    78 (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
       
    79 Using them while a different <code>LookAndFeel</code> is installed
       
    80 may produce unexpected results, including exceptions.
       
    81 Additionally, changing the <code>LookAndFeel</code>
       
    82 maintained by the <code>UIManager</code> without updating the
       
    83 corresponding <code>ComponentUI</code> of any
       
    84 <code>JComponent</code>s may also produce unexpected results,
       
    85 such as the wrong colors showing up, and is generally not
       
    86 encouraged.
       
    87 
       
    88 <p><strong>Note:</strong>
       
    89 Most of the Swing API is <em>not</em> thread safe.
       
    90 For details, see
       
    91 <a href="http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html"
       
    92    target="_top">Concurrency in Swing</a>,
       
    93 a section in
       
    94 <em><a href="http://java.sun.com/docs/books/tutorial/"
       
    95        target="_top">The Java Tutorial</a></em>.
       
    96 
       
    97 @since 1.7
       
    98 @serial exclude
       
    99 
       
   100 </body>
       
   101 </html>