author | peterz |
Tue, 23 Jun 2009 12:24:11 +0400 | |
changeset 3094 | abb391749982 |
parent 2658 | 43e06bc950ec |
child 4394 | 92a8ec883f5d |
permissions | -rw-r--r-- |
2658 | 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> |
2 |
<html> |
|
3 |
<head> |
|
4 |
<!-- |
|
5 |
Copyright 1998-2001 Sun Microsystems, Inc. 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. Sun designates this |
|
11 |
particular file as subject to the "Classpath" exception as provided |
|
12 |
by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
25 |
CA 95054 USA or visit www.sun.com if you need additional information or |
|
26 |
have any questions. |
|
27 |
--> |
|
28 |
||
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 |
|
3094
abb391749982
6844273: jdk/make/docs/CORE_PKGS.gmk does not list Nimbus
peterz
parents:
2658
diff
changeset
|
41 |
altering the {@link javax.swing.UIDefaults} table. Here's an example: |
2658 | 42 |
<code><pre> |
43 |
UIManager.put("ProgressBar.tileWidth", myTileWidth); |
|
44 |
UIManager.put("ProgressBar[Enabled].backgroundPainter", myBgPainter); |
|
45 |
UIManager.put("ProgressBar[Enabled].foregroundPainter", myFgPainter); |
|
46 |
</pre></code> |
|
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 |
<code><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></code> |
|
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 |
|
92 |
href="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html" |
|
93 |
target="_top">Threads and Swing</a>, |
|
94 |
a section in |
|
95 |
<em><a href="http://java.sun.com/docs/books/tutorial/" |
|
96 |
target="_top">The Java Tutorial</a></em>. |
|
97 |
||
98 |
@since 1.7 |
|
99 |
@serial exclude |
|
100 |
||
101 |
</body> |
|
102 |
</html> |