src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 38388 jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html@84ab1f133f16
child 48264 efda6932a433
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
<HTML>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
<HEAD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
<TITLE>Using the Multiplexing Look and Feel</TITLE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
</HEAD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
<b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
<font size=+3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
Using the Multiplexing Look and Feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
</font>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
<blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
<hr>
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
    17
<p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
<i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
This document is based on an article
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
originally published in
38388
84ab1f133f16 8143346: Broken link in java.beans.XMLEncoder
serb
parents: 27565
diff changeset
    21
<a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html" target="_top"><em>The Swing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
Connection</em></a>.
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
    23
</i>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
<hr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
</blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
The Multiplexing look and feel lets
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
you supplement an ordinary look and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
(called the <em>default</em> look and feel)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
with one or more <em>auxiliary</em> look and feels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
For example, you could
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
simultaneously provide text-to-speech and Braille outputs, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
in addition to the ordinary visual output that a Swing-based 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
application generates,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
by adding 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
two auxiliary look and feels (one for text-to-speech,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
the other for Braille)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
to the default look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
The default look and feel can be any ordinary look and feel --
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
the Java or Windows look and feel, for example --
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
and requires no modifications to work with auxiliary look and feels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
This document has the following sections:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
<li> <a href="#overview">Overview</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
<li> <a href="#howtouse">How to Use Auxiliary Look and Feels</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
<li> <a href="#howtowrite">Tips for Writing an Auxiliary Look and Feel</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     <li> <a href="#dosanddonts">Dos and Don'ts</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     <li> <a href="#uidefaults">Extending UIDefaults</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     <li> <a href="#defaultui">Examining Other UI Objects</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
<li> <a href="#implementation">How the Multiplexing Look and Feel is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     Implemented</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
<li> <a href="#custom">How to Provide a Custom Multiplexing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     Look and Feel</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
Before reading further, you should be familiar 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
with the concept of pluggable look and feels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
For basic information, see
38388
84ab1f133f16 8143346: Broken link in java.beans.XMLEncoder
serb
parents: 27565
diff changeset
    68
<a href="https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html">How to Set the Look and Feel</a>,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
a section in 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
<em>The Java Tutorial</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
For architectural details, you can read
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
<a
38388
84ab1f133f16 8143346: Broken link in java.beans.XMLEncoder
serb
parents: 27565
diff changeset
    73
href="http://www.oracle.com/technetwork/java/architecture-142923.html#pluggable">Pluggable look-and-feel architecture</a>, a section within
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
a <em>Swing Connection</em> article.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
<p> 
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
    78
<a name="overview"></a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
<hr width=100% align=LEFT size=2>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
<b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
<font color="#000080" size="+2">Overview</font>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
The classes in the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
<code>javax.swing.plaf.multi</code> package
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
implement a 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
<i>multiplexing look and feel</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
A multiplexing look and feel transparently creates -- and 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
simultaneously supports -- UI objects from several different look and feels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
in response to a component requesting its UI object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
(with the <code>getUI</code> method).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
Without a multiplexing look and feel, a 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
developer who wanted to enhance a particular look and feel would 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
need to extend the classes supporting that look and feel. For example, to 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
add text-to-speech support to the Java look and feel without using a multiplexing 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
look and feel, the developer would need to create a group of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
classes that extend those of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
the Java look and feel, and add text-to-speech support to the new classes. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
If the developer also wanted to add text-to-speech support to other look
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
and feels, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
such as Motif or Windows, the developers would need to create subclasses 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
of those classes as well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
This approach has at least two shortcomings: 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
<ul type="DISC">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  <li>First, each subclass must use what is 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
      essentially a copy of the same code, potentially creating a difficult 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
      support situation for the developer.<br></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  <li>Second, and more significantly for the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
      end user, some application developers might force a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
      particular look and feel to be used. When this approach is used, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
      the end user can't even use the enhanced look and feel.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
A multiplexing look and feel 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
both these problems simultaneously because it allows multiple look 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
and feels to be combined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
The first problem (having to use what amounts to a second copy of the same 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
code) is solved because the developer can create a specialized look 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
and feel that can then be combined with other look and feels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
The second problem (having to force the use of 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
a particular look and feel) is solved because a specialized look and feel 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
can be used with whatever default look and feel the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
application may have locked in place.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
The default multiplexing look and feel implementation, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
represented by the <code>MultiLookAndFeel</code> class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
in the <code>javax.swing.plaf.multi</code> package,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
is called (unsurprisingly) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
the Multiplexing look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
<p> 
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   146
<a name="howtouse"></a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
<hr width=100% align=LEFT size=2>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
<b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
<font color="#000080" size="+2">How to Use Auxiliary Look and Feels</font>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
It's easy to use auxiliary look and feels with Swing. To instruct 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
Swing to use the Multiplexing look and feel, all an application 
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
   156
has to do is modify the <code>$JDKHOME/conf/swing.properties</code>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
file to include a definition of the <code>swing.auxiliarylaf</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
property. Swing treats the <code>swing.auxiliarylaf</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
property as a comma-separated list of <code>LookAndFeel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
subclasses that specify what auxiliary look and feels should be 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
used in addition to the default look and feel. If at least one valid 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
<code>LookAndFeel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
subclass is specified in the <code>swing.auxiliarylaf</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
property, Swing automatically uses the Multiplexing look and feel 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
to load and support the default and auxiliary look and feels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
For example, let's assume that an application 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
makes use of a look and feel that supports text-to-speech feedback, and also 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
uses an look and feel that adds support for a device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
that emits perfume.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
Let's assume that the text-to-speech
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
look and feel is named <code>com.myco.TextTalkerLookAndFeel</code>, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
and the look and feel that adds support for perfume
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
is named <code>com.smellco.OlfactoryLookAndFeel</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
To tell Swing to use both these look and feels 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
-- and to use a default look and feel at the same time -- your application 
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
   182
could simply add the following line to the <code>$JDKHOME/conf/swing.properties</code> file:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
<code>&nbsp;&nbsp;&nbsp; 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
              swing.auxiliarylaf=com.myco.TextTalkerLookAndFeel,<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; com.smellco.OlfactoryLookAndFeel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
This statement tells Swing to obtain a component's UI from the Multiplexing 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
look and feel automatically, instead of obtaining it directly from 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
the default look and feel. The resulting multiplexing UI is a small 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
delegate that obtains and maintains UIs from the default and auxiliary 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
look and feels. As a result, when a method is invoked in a multiplexing 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
UI object, the multiplexing UI invokes the same method on each 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
of the UIs obtained from the default and auxiliary look and feels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
<p> 
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   202
<a name="howtowrite"></a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
<hr width=100% align=LEFT size=2>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
<b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
<font color="#000080" size="+2">Tips for Writing an Auxiliary Look and Feel</font>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
An auxiliary look and feel is like any other look and feel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
except that it doesn't have to provide the complete support 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
that a default look and feel must. For 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
example, an auxiliary look and feel that supports just text-to-speech feedback 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
doesn't need to provide any code for painting. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
Also, it might not need to support all components --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
<code>JSeparator</code>s, for example, might be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
Auxiliary look and feels tend to be simple,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
so developing one can be easier than developing a visual 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
The developer can concentrate solely 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
on providing the specialized functionality. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
Because the primary purpose of an auxiliary look and feel is to enhance the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
default look and feel, auxiliary look and feels tend 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
be nonvisual. Since an auxiliary look and feel is a genuine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
look and feel, however, there is nothing to prevent it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
from rendering information on the display.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
Just like for any other look and feel, you
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
implement an auxiliary look and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
by writing a subclass of <code>javax.swing.LookAndFeel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
and creating subclasses of the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
<code><em>Foo</em>UI</code> classes defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
the <code>javax.swing.plaf</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
<p> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
<a name="dosanddonts">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
<font color="#000080" size="+1"><b>Dos and Don'ts</b></font> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
The following paragraphs provide some general recommendations for developing 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
auxiliary look and feels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
<font color="#000080"><b>Use the <code>installUI</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
to perform all initialization,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
and the <code>uninstallUI</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
to perform all cleanup.</b></font>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
</p>
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   260
<blockquote>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
The <code>installUI</code> and <code>uninstallUI</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
methods are invoked when a component's look and feel is set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
The <code>installUI</code> method gives the new UI object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
a chance to add listeners on the component and its data model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
Similarly, the <code>uninstallUI</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
lets the previous UI object remove its listeners.
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   267
</blockquote>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            <p> <font color="#000080"><b>Don't extend 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
              visual look and feels.</b></font></p>
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   270
<blockquote>
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   271
               We recommended that you <i>don't</i> implement 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                UI classes of an auxiliary look and feel as subclasses of the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                UI classes of a visual look and feel. Why not? Because they might 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                accidentally inherit code that installs listeners on a component 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                object or renders the component on the display. As a result, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                your auxiliary look and feel would compete with the default look 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                and feel rather than cooperating with it.<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                Instead, we recommend that the UI classes of an auxiliary look 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                and feel directly extend the abstract UI classes in the <code>javax.swing.plaf</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                package. By using this strategy, the developer of an auxiliary 
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   282
                look and feel can avoid competing with the default look and feel.
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   283
</blockquote>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            <p> <font color="#000080"><b>Override all UI-specific methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
	    your UI classes inherit.</b></font>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
	    </p>
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   287
<blockquote>
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   288
               We recommend that each UI class of 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                an auxiliary look and feel override the methods 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
		defined in the <code>javax.swing.plaf</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                UI classes it descends from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
		The reasons for this recommendation are similar 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                to those for not extending a visual look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                For example, the <code>ComponentUI</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                class, from which all UI classes descend,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
		provides a default implementation for the <code>update</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                method. This default implementation paints on the display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
		if the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                component is opaque. If a UI class from a non-visual auxiliary 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                look and feel does not override this method, all 
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   301
                opaque components appear as blank areas on the screen!
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   302
</blockquote>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            <p> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
<a name="uidefaults">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
<font color="#000080" size="+1"><b>Extending UIDefaults</b></font> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            <p>In many cases, you 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
              might want an auxiliary look and feel to be &quot;incomplete.&quot; That 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
              is, you might not need to support the complete set 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
              of components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            For example, an auxiliary look and feel might choose 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
	    to provide a <code>ButtonUI</code> subclass but no 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
              <code>LabelUI</code> subclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
	     This 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
              option is allowed, and the multiplexing look and feel gracefully 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
              handles such situations.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            <p>By default, however, Swing issues an error message when it asks 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
              a look and feel for a UI object and the look and feel does not 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
              support that UI. This message can be annoying, especially to auxiliary 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
              look-and-feel developers who don't want to support a particular 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
              component.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            <p>Fortunately, you can prevent this error 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
              message by creating a subclass of the <code>UIDefaults</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
              class and returning an instance of it from the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
	      <code>getDefaults</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
	      of your <code>LookAndFeel</code> class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
	      For example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
	      </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            <p><code>public class MyAuxLookAndFeel 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
              extends LookAndFeel {<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                  ...<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                  public UIDefaults getDefaults() {<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                      <b>UIDefaults table = <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
              new MyAuxUIDefaults();<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
              </b>        Object[] uiDefaults = {<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                        &quot;ButtonUI&quot;, &quot;MyAuxButtonUI&quot;,<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                        ...<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                      }<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                      table.putDefaults(uiDefaults);<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                      return table;<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                  }<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
              }<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
              <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
              <b>class MyAuxUIDefaults extends UIDefaults {<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                  protected void getUIError(String msg) {<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                      //System.err.println<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp; (&quot;An 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
              annoying message!&quot;);<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                  }<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
              }</b></code></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
In the preceding example, an auxiliary look and feel named <code>MyAux</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
              creates a <code>UIDefaults</code> subclass 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
              that overrides the <code>getUIError</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
              method. The <code>getUIError</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
              method is the method that is invoked when Swing cannot find a UI 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
              object in a look and feel. By merely doing nothing in this method, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
              you can avoid the error message.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            <p> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
<a name="defaultui">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
<b><font color="#000080" size="+1">Examining Other UI Objects</font></b> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            <p>In 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
              rare instances, a UI object from an auxiliary look and feel 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
              may be interested in the default UI object used by the component. In 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
              these cases, the UI object from auxiliary look and feel can obtain 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
              the UI from a component by calling its <code>getUI</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
              method. The returned UI is an instance of one of the multiplexing 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
              look and feel UI classes (for example, <code>MultiButtonUI</code>). 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
              The UI object from the auxiliary look and feel can call the <code>getUIs</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
              method of the returned object to obtain an array containing a complete list 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
              of all UI objects handled by the multiplexing UI. The first element 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
              is guaranteed to be the UI created from the default look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
	      </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
<p> 
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   385
<a name="implementation"></a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
<hr width=100% align=LEFT size=2>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
<font color="#000080" size="+2"><b>How the Multiplexing Look and Feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
Is Implemented</b></font> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
The Multiplexing look and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
(represented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
<code>javax.swing.plaf.multi.MultiLookAndFeel</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
is meant to be transparent to 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
all developers and users. It should &quot;just work&quot; -- and 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
              it is used only when the user tells Swing to use an auxiliary look 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
              and feel.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
              When the Multiplexing look and 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
              feel is in use, the type of the UI object 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
	      associated with each component 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
	      depends on whether 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
	      any of the auxiliary look and feels currently in use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
	      support the component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
	      If so, the component's UI object is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
	      an instance of a multiplexing UI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
	      If only the default look and feel supports the component,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
	      then the component gets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
              a UI object from the default look and feel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
	      just as if no auxiliary look and feels were installed. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
	      <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
	      A multiplexing UI object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
              obtains and maintains UI objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
	      from the default and auxiliary look
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
	      and feels,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
              referring to these UIs in the following manner: 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
<ul type="DISC">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
              <li> The UI object from the default look 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                and feel is always the first to be created. After that, a UI object 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                is created from each auxiliary look and feel in the order 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                they are specified in the <code>swing.auxiliarylaf</code> 
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   425
                property.<br><br></li>
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   426
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
              <li> When a method that requests information 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                from a UI object is invoked, the multiplexing UI object 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
		invokes the method on all the UI objects, but returns 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                only the results from the UI for the default look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                For example, when the <code>getPreferredSize</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                method is invoked on a multiplexing UI, the UI returns only the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                results of invoking <code>getPreferredSize</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                on the UI obtained from the default look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
		The <code>getPreferredSize</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
		is also invoked on the UI object for each auxiliary look and feel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
		but the return values are ignored.
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   438
                <br><br></li>
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   439
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
              <li> When a method that does not request information 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                from the UI object is invoked, the multiplexing UI object 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                invokes that method on all UIs --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
		on the UI object obtained from the default look
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
		and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                and on all the UIs obtained from the auxiliary look and feels,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
		as well. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                For example, invoking the <code>installUI</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                method on a multiplexing UI causes the multiplexing UI to invoke 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                <code>installUI</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                on the UI obtained from the default look and feel and the UIs obtained from 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                the auxiliary factories.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            <p> In all cases, the UI object obtained from 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
              the default look and feel is acted upon first, and then the auxiliary 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
              look and feels are acted upon in the order they are specified in 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
              the <code>swing.auxiliarylaf</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
              property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
<p> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   462
<a name="custom"></a>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
<hr width=100% align=LEFT size=2>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
<font color="#000080" size="+2"><b>How to Provide a Custom Multiplexing Look
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
and Feel</b></font> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
21254
f6d36ee3f269 8025824: [cleanup] Fix tidy errors and warnings in preformatted HTML files related to 2d/awt/swing
yan
parents: 7959
diff changeset
   467
            <p>While 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
              we hope the behavior of the Multiplexing look and feel is 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
              flexible enough not to require an alternative multiplexing look 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
              and feel, Swing allows the user to specify another multiplexing look 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
              and feel to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            <p> To do that, all the user has to do is modify 
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
   475
              the <code>$JDKHOME/conf/swing.properties</code> 
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
              file to include a definition of the <code>swing.plaf.multiplexinglaf</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
              property. Swing then treats the <code>swing.plaf.multiplexinglaf</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
              property as a <code>LookAndFeel</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
              subclass that supports multiplexing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            <p> For example, if a user has a multiplexing 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
              look and feel represented by <code>com.myco.SuperMultiLookAndFeel</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
              that is a better match for their needs than the Multiplexing 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
              look and feel 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
	      (<code>javax.swing.plaf.multi.MultiLookAndFeel</code>), 
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
   486
              the user could include the following line in <code>$JDKHOME/conf/swing.properties</code>:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
<code>swing.plaf.multiplexinglaf = com.myco.SuperMultiLookAndFeel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
This statement instructs Swing to use <code>com.myco.SuperMultiLookAndFeel</code> 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
instead of <code>javax.swing.plaf.multi.MultiLookAndFeel</code>. But 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
if you use this kind of statement, be careful, because the suppliers 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
of auxiliary look and feels will most likely have developed and 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
tested against our Multiplexing look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
</BODY>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
</HTML>