< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html

Print this page

        

*** 1,27 **** ! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> ! <HTML> ! <HEAD> ! <TITLE>Using the Multiplexing Look and Feel</TITLE> ! </HEAD> ! ! <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> ! ! <b> ! <font size=+3> ! Using the Multiplexing Look and Feel ! </font> ! </b> <blockquote> <hr> <p> <i> This document is based on an article originally published in ! <a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html" target="_top"><em>The Swing ! Connection</em></a>. </i> </p> <hr> </blockquote> --- 1,48 ---- ! <!doctype html> ! <html lang="en"> ! <head> ! <meta charset="utf-8"/> ! <title>Using the Multiplexing Look and Feel</title> ! </head> ! <!-- ! Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. ! DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ! ! This code is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License version 2 only, as ! published by the Free Software Foundation. Oracle designates this ! particular file as subject to the "Classpath" exception as provided ! by Oracle in the LICENSE file that accompanied this code. ! ! This code is distributed in the hope that it will be useful, but WITHOUT ! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ! FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ! version 2 for more details (a copy is included in the LICENSE file that ! accompanied this code). ! ! You should have received a copy of the GNU General Public License version ! 2 along with this work; if not, write to the Free Software Foundation, ! Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ! ! Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ! or visit www.oracle.com if you need additional information or have any ! questions. ! --> ! ! <body> ! ! <h1>Using the Multiplexing Look and Feel</h1> <blockquote> <hr> <p> <i> This document is based on an article originally published in ! <a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html" ! target="_top"><em>The Swing Connection</em></a>. </i> </p> <hr> </blockquote>
*** 63,88 **** <p> Before reading further, you should be familiar with the concept of pluggable look and feels. For basic information, see ! <a href="https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html">How to Set the Look and Feel</a>, ! a section in ! <em>The Java Tutorial</em>. For architectural details, you can read <a ! href="http://www.oracle.com/technetwork/java/architecture-142923.html#pluggable">Pluggable look-and-feel architecture</a>, a section within a <em>Swing Connection</em> article. </p> <p> ! <a name="overview"></a> ! <hr width=100% align=LEFT size=2> ! <b> ! <font color="#000080" size="+2">Overview</font> ! </b> ! <p> The classes in the <code>javax.swing.plaf.multi</code> package --- 84,106 ---- <p> Before reading further, you should be familiar with the concept of pluggable look and feels. For basic information, see ! <a href="https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html"> ! How to Set the Look and Feel</a>, a section in <em>The Java Tutorial</em>. For architectural details, you can read <a ! href="http://www.oracle.com/technetwork/java/architecture-142923.html#pluggable"> ! Pluggable look-and-feel architecture</a>, a section within a <em>Swing Connection</em> article. </p> <p> ! <a id="overview"></a> ! <hr> ! <h2>Overview</h2> <p> The classes in the <code>javax.swing.plaf.multi</code> package
*** 107,117 **** of those classes as well. </p> <p> This approach has at least two shortcomings: ! <ul type="DISC"> <li>First, each subclass must use what is essentially a copy of the same code, potentially creating a difficult support situation for the developer.<br></li> <li>Second, and more significantly for the end user, some application developers might force a --- 125,135 ---- of those classes as well. </p> <p> This approach has at least two shortcomings: ! <ul> <li>First, each subclass must use what is essentially a copy of the same code, potentially creating a difficult support situation for the developer.<br></li> <li>Second, and more significantly for the end user, some application developers might force a
*** 141,156 **** in the <code>javax.swing.plaf.multi</code> package, is called (unsurprisingly) the Multiplexing look and feel. <p> ! <a name="howtouse"></a> ! <hr width=100% align=LEFT size=2> ! <b> ! <font color="#000080" size="+2">How to Use Auxiliary Look and Feels</font> ! </b> ! <p> It's easy to use auxiliary look and feels with Swing. To instruct Swing to use the Multiplexing look and feel, all an application has to do is modify the <code>$JDKHOME/conf/swing.properties</code> --- 159,171 ---- in the <code>javax.swing.plaf.multi</code> package, is called (unsurprisingly) the Multiplexing look and feel. <p> ! <a id="howtouse"></a> ! <hr> ! <h2>How to Use Auxiliary Look and Feels</h2> <p> It's easy to use auxiliary look and feels with Swing. To instruct Swing to use the Multiplexing look and feel, all an application has to do is modify the <code>$JDKHOME/conf/swing.properties</code>
*** 197,212 **** UI object, the multiplexing UI invokes the same method on each of the UIs obtained from the default and auxiliary look and feels. </p> <p> ! <a name="howtowrite"></a> ! <hr width=100% align=LEFT size=2> ! <b> ! <font color="#000080" size="+2">Tips for Writing an Auxiliary Look and Feel</font> ! </b> ! <p> An auxiliary look and feel is like any other look and feel, except that it doesn't have to provide the complete support that a default look and feel must. For --- 212,224 ---- UI object, the multiplexing UI invokes the same method on each of the UIs obtained from the default and auxiliary look and feels. </p> <p> ! <a id="howtowrite"></a> ! <hr> ! <h2>Tips for Writing an Auxiliary Look and Feel</h2> <p> An auxiliary look and feel is like any other look and feel, except that it doesn't have to provide the complete support that a default look and feel must. For
*** 237,291 **** and creating subclasses of the <code><em>Foo</em>UI</code> classes defined in the <code>javax.swing.plaf</code> package. </p> ! <p> ! <br> ! <a name="dosanddonts"> ! <font color="#000080" size="+1"><b>Dos and Don'ts</b></font> </a> - </p> <p> The following paragraphs provide some general recommendations for developing auxiliary look and feels. </p> <p> ! <font color="#000080"><b>Use the <code>installUI</code> method to perform all initialization, and the <code>uninstallUI</code> method ! to perform all cleanup.</b></font> ! </p> <blockquote> The <code>installUI</code> and <code>uninstallUI</code> methods are invoked when a component's look and feel is set. The <code>installUI</code> method gives the new UI object a chance to add listeners on the component and its data model. Similarly, the <code>uninstallUI</code> method lets the previous UI object remove its listeners. </blockquote> ! <p> <font color="#000080"><b>Don't extend ! visual look and feels.</b></font></p> <blockquote> We recommended that you <i>don't</i> implement UI classes of an auxiliary look and feel as subclasses of the ! UI classes of a visual look and feel. Why not? Because they might accidentally inherit code that installs listeners on a component ! object or renders the component on the display. As a result, your auxiliary look and feel would compete with the default look and feel rather than cooperating with it.<br> <br> Instead, we recommend that the UI classes of an auxiliary look and feel directly extend the abstract UI classes in the <code>javax.swing.plaf</code> ! package. By using this strategy, the developer of an auxiliary look and feel can avoid competing with the default look and feel. </blockquote> ! <p> <font color="#000080"><b>Override all UI-specific methods ! your UI classes inherit.</b></font> ! </p> <blockquote> We recommend that each UI class of an auxiliary look and feel override the methods defined in the <code>javax.swing.plaf</code> UI classes it descends from --- 249,298 ---- and creating subclasses of the <code><em>Foo</em>UI</code> classes defined in the <code>javax.swing.plaf</code> package. </p> ! <a id="dosanddonts"> ! <h3>Dos and Don'ts</h3> </a> <p> The following paragraphs provide some general recommendations for developing auxiliary look and feels. </p> <p> ! <h4>Use the <code>installUI</code> method to perform all initialization, and the <code>uninstallUI</code> method ! to perform all cleanup.</h4> ! <blockquote> The <code>installUI</code> and <code>uninstallUI</code> methods are invoked when a component's look and feel is set. The <code>installUI</code> method gives the new UI object a chance to add listeners on the component and its data model. Similarly, the <code>uninstallUI</code> method lets the previous UI object remove its listeners. </blockquote> ! <h4><b>Don't extend visual look and feels.</b></h4> <blockquote> We recommended that you <i>don't</i> implement UI classes of an auxiliary look and feel as subclasses of the ! UI classes of a visual look and feel. Why not? Because they might accidentally inherit code that installs listeners on a component ! object or renders the component on the display. As a result, your auxiliary look and feel would compete with the default look and feel rather than cooperating with it.<br> <br> Instead, we recommend that the UI classes of an auxiliary look and feel directly extend the abstract UI classes in the <code>javax.swing.plaf</code> ! package. By using this strategy, the developer of an auxiliary look and feel can avoid competing with the default look and feel. </blockquote> ! <h4><b>Override all UI-specific methods your UI classes inherit.</b></h4> ! <blockquote> We recommend that each UI class of an auxiliary look and feel override the methods defined in the <code>javax.swing.plaf</code> UI classes it descends from
*** 298,316 **** if the component is opaque. If a UI class from a non-visual auxiliary look and feel does not override this method, all opaque components appear as blank areas on the screen! </blockquote> - <p> ! <br> ! <a name="uidefaults"> ! <font color="#000080" size="+1"><b>Extending UIDefaults</b></font> ! </a> <p>In many cases, you ! might want an auxiliary look and feel to be &quot;incomplete.&quot; That is, you might not need to support the complete set of components. For example, an auxiliary look and feel might choose to provide a <code>ButtonUI</code> subclass but no <code>LabelUI</code> subclass. --- 305,320 ---- if the component is opaque. If a UI class from a non-visual auxiliary look and feel does not override this method, all opaque components appear as blank areas on the screen! </blockquote> ! <a id="uidefaults"></a> ! <h3>Extending UIDefaults</h3> <p>In many cases, you ! might want an auxiliary look and feel to be &quot;incomplete.&quot; That is, you might not need to support the complete set of components. For example, an auxiliary look and feel might choose to provide a <code>ButtonUI</code> subclass but no <code>LabelUI</code> subclass.
*** 329,400 **** of your <code>LookAndFeel</code> class. For example: </p> <p><code>public class MyAuxLookAndFeel extends LookAndFeel {<br> !     ...<br> !     public UIDefaults getDefaults() {<br> !         <b>UIDefaults table = <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new MyAuxUIDefaults();<br> ! </b>        Object[] uiDefaults = {<br> !           &quot;ButtonUI&quot;, &quot;MyAuxButtonUI&quot;,<br> !           ...<br> !         }<br> !         table.putDefaults(uiDefaults);<br> !         return table;<br> !     }<br> }<br> <br> <b>class MyAuxUIDefaults extends UIDefaults {<br> !     protected void getUIError(String msg) {<br> !         //System.err.println<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp; (&quot;An annoying message!&quot;);<br> !     }<br> }</b></code></p> <p> In the preceding example, an auxiliary look and feel named <code>MyAux</code> creates a <code>UIDefaults</code> subclass that overrides the <code>getUIError</code> ! method. The <code>getUIError</code> method is the method that is invoked when Swing cannot find a UI ! object in a look and feel. By merely doing nothing in this method, you can avoid the error message.</p> <p> ! <br> ! <a name="defaultui"> ! <b><font color="#000080" size="+1">Examining Other UI Objects</font></b> ! </a> <p>In rare instances, a UI object from an auxiliary look and feel ! may be interested in the default UI object used by the component. In these cases, the UI object from auxiliary look and feel can obtain the UI from a component by calling its <code>getUI</code> ! method. The returned UI is an instance of one of the multiplexing look and feel UI classes (for example, <code>MultiButtonUI</code>). The UI object from the auxiliary look and feel can call the <code>getUIs</code> method of the returned object to obtain an array containing a complete list of all UI objects handled by the multiplexing UI. The first element is guaranteed to be the UI created from the default look and feel. </p> <p> ! <a name="implementation"></a> ! <hr width=100% align=LEFT size=2> ! <font color="#000080" size="+2"><b>How the Multiplexing Look and Feel ! Is Implemented</b></font> <p> The Multiplexing look and feel (represented by <code>javax.swing.plaf.multi.MultiLookAndFeel</code>) is meant to be transparent to ! all developers and users. It should &quot;just work&quot; -- and it is used only when the user tells Swing to use an auxiliary look and feel.</p> <p> When the Multiplexing look and --- 333,401 ---- of your <code>LookAndFeel</code> class. For example: </p> <p><code>public class MyAuxLookAndFeel extends LookAndFeel {<br> ! ...<br> ! public UIDefaults getDefaults() {<br> ! <b>UIDefaults table = <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new MyAuxUIDefaults();<br> ! </b> Object[] uiDefaults = {<br> ! &quot;ButtonUI&quot;, &quot;MyAuxButtonUI&quot;,<br> ! ...<br> ! }<br> ! table.putDefaults(uiDefaults);<br> ! return table;<br> ! }<br> }<br> <br> <b>class MyAuxUIDefaults extends UIDefaults {<br> ! protected void getUIError(String msg) {<br> ! //System.err.println<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp; (&quot;An annoying message!&quot;);<br> ! }<br> }</b></code></p> <p> In the preceding example, an auxiliary look and feel named <code>MyAux</code> creates a <code>UIDefaults</code> subclass that overrides the <code>getUIError</code> ! method. The <code>getUIError</code> method is the method that is invoked when Swing cannot find a UI ! object in a look and feel. By merely doing nothing in this method, you can avoid the error message.</p> <p> ! <a id="defaultui"></a> ! <h3>Examining Other UI Objects</h3> <p>In rare instances, a UI object from an auxiliary look and feel ! may be interested in the default UI object used by the component. In these cases, the UI object from auxiliary look and feel can obtain the UI from a component by calling its <code>getUI</code> ! method. The returned UI is an instance of one of the multiplexing look and feel UI classes (for example, <code>MultiButtonUI</code>). The UI object from the auxiliary look and feel can call the <code>getUIs</code> method of the returned object to obtain an array containing a complete list of all UI objects handled by the multiplexing UI. The first element is guaranteed to be the UI created from the default look and feel. </p> <p> ! <a id="implementation"></a> ! <hr> ! <h2>How the Multiplexing Look and Feel Is Implemented</h2> <p> The Multiplexing look and feel (represented by <code>javax.swing.plaf.multi.MultiLookAndFeel</code>) is meant to be transparent to ! all developers and users. It should &quot;just work&quot; -- and it is used only when the user tells Swing to use an auxiliary look and feel.</p> <p> When the Multiplexing look and
*** 415,425 **** obtains and maintains UI objects from the default and auxiliary look and feels, referring to these UIs in the following manner: ! <ul type="DISC"> <li> The UI object from the default look and feel is always the first to be created. After that, a UI object is created from each auxiliary look and feel in the order they are specified in the <code>swing.auxiliarylaf</code> property.<br><br></li> --- 416,426 ---- obtains and maintains UI objects from the default and auxiliary look and feels, referring to these UIs in the following manner: ! <ul> <li> The UI object from the default look and feel is always the first to be created. After that, a UI object is created from each auxiliary look and feel in the order they are specified in the <code>swing.auxiliarylaf</code> property.<br><br></li>
*** 457,470 **** property. </p> <p> ! <a name="custom"></a> ! <hr width=100% align=LEFT size=2> ! <font color="#000080" size="+2"><b>How to Provide a Custom Multiplexing Look ! and Feel</b></font> <p>While we hope the behavior of the Multiplexing look and feel is flexible enough not to require an alternative multiplexing look and feel, Swing allows the user to specify another multiplexing look --- 458,470 ---- property. </p> <p> ! <a id="custom"></a> ! <hr> ! <h2>How to Provide a Custom Multiplexing Look and Feel</h2> <p>While we hope the behavior of the Multiplexing look and feel is flexible enough not to require an alternative multiplexing look and feel, Swing allows the user to specify another multiplexing look
*** 472,482 **** </p> <p> To do that, all the user has to do is modify the <code>$JDKHOME/conf/swing.properties</code> file to include a definition of the <code>swing.plaf.multiplexinglaf</code> ! property. Swing then treats the <code>swing.plaf.multiplexinglaf</code> property as a <code>LookAndFeel</code> subclass that supports multiplexing. </p> <p> For example, if a user has a multiplexing look and feel represented by <code>com.myco.SuperMultiLookAndFeel</code> --- 472,482 ---- </p> <p> To do that, all the user has to do is modify the <code>$JDKHOME/conf/swing.properties</code> file to include a definition of the <code>swing.plaf.multiplexinglaf</code> ! property. Swing then treats the <code>swing.plaf.multiplexinglaf</code> property as a <code>LookAndFeel</code> subclass that supports multiplexing. </p> <p> For example, if a user has a multiplexing look and feel represented by <code>com.myco.SuperMultiLookAndFeel</code>
*** 496,502 **** if you use this kind of statement, be careful, because the suppliers of auxiliary look and feels will most likely have developed and tested against our Multiplexing look and feel. </p> ! </BODY> ! </HTML> --- 496,502 ---- if you use this kind of statement, be careful, because the suppliers of auxiliary look and feels will most likely have developed and tested against our Multiplexing look and feel. </p> ! </body> ! </html>
< prev index next >