< prev index next >

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

Print this page




 274         // includes a class outside of javax.swing, thus we cannot call setUIProperty
 275         // directly.
 276         if (SunToolkit.isInstanceOf(c, "javax.swing.JPasswordField")) {
 277             if (!((JPasswordField)c).customSetUIProperty(propertyName, propertyValue)) {
 278                 c.setUIProperty(propertyName, propertyValue);
 279             }
 280         } else {
 281             c.setUIProperty(propertyName, propertyValue);
 282         }
 283     }
 284 
 285     /**
 286      * Convenience method for building an array of {@code
 287      * KeyBindings}. While this method is not deprecated, developers
 288      * should instead use {@code ActionMap} and {@code InputMap} for
 289      * supplying key bindings.
 290      * <p>
 291      * This method returns an array of {@code KeyBindings}, one for each
 292      * alternating {@code key-action} pair in {@code keyBindingList}.
 293      * A {@code key} can either be a {@code String} in the format
 294      * specified by the <code>KeyStroke.getKeyStroke</code> method, or
 295      * a {@code KeyStroke}. The {@code action} part of the pair is a
 296      * {@code String} that corresponds to the name of the {@code
 297      * Action}.
 298      * <p>
 299      * The following example illustrates creating a {@code KeyBinding} array
 300      * from six alternating {@code key-action} pairs:
 301      * <pre>
 302      *  JTextComponent.KeyBinding[] multilineBindings = makeKeyBindings( new Object[] {
 303      *          "UP", DefaultEditorKit.upAction,
 304      *        "DOWN", DefaultEditorKit.downAction,
 305      *     "PAGE_UP", DefaultEditorKit.pageUpAction,
 306      *   "PAGE_DOWN", DefaultEditorKit.pageDownAction,
 307      *       "ENTER", DefaultEditorKit.insertBreakAction,
 308      *         "TAB", DefaultEditorKit.insertTabAction
 309      *  });
 310      * </pre>
 311      * If {@code keyBindingList's} length is odd, the last element is
 312      * ignored.
 313      * <p>
 314      * Supplying a {@code null} value for either the {@code key} or


 329      * @see InputMap
 330      * @see KeyStroke#getKeyStroke
 331      */
 332     public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList)
 333     {
 334         JTextComponent.KeyBinding[] rv = new JTextComponent.KeyBinding[keyBindingList.length / 2];
 335 
 336         for(int i = 0; i < rv.length; i ++) {
 337             Object o = keyBindingList[2 * i];
 338             KeyStroke keystroke = (o instanceof KeyStroke)
 339                 ? (KeyStroke) o
 340                 : KeyStroke.getKeyStroke((String) o);
 341             String action = (String) keyBindingList[2 * i + 1];
 342             rv[i] = new JTextComponent.KeyBinding(keystroke, action);
 343         }
 344 
 345         return rv;
 346     }
 347 
 348     /**
 349      * Creates a {@code InputMapUIResource} from <code>keys</code>. This is
 350      * a convenience method for creating a new {@code InputMapUIResource},
 351      * invoking {@code loadKeyBindings(map, keys)}, and returning the
 352      * {@code InputMapUIResource}.
 353      *
 354      * @param keys alternating pairs of {@code keystroke-action key}
 355      *        pairs as described in {@link #loadKeyBindings}
 356      * @return newly created and populated {@code InputMapUIResource}
 357      * @see #loadKeyBindings
 358      *
 359      * @since 1.3
 360      */
 361     public static InputMap makeInputMap(Object[] keys) {
 362         InputMap retMap = new InputMapUIResource();
 363         loadKeyBindings(retMap, keys);
 364         return retMap;
 365     }
 366 
 367     /**
 368      * Creates a {@code ComponentInputMapUIResource} from
 369      * <code>keys</code>. This is a convenience method for creating a
 370      * new {@code ComponentInputMapUIResource}, invoking {@code
 371      * loadKeyBindings(map, keys)}, and returning the {@code
 372      * ComponentInputMapUIResource}.
 373      *
 374      * @param c component to create the {@code ComponentInputMapUIResource}
 375      *          with
 376      * @param keys alternating pairs of {@code keystroke-action key}
 377      *        pairs as described in {@link #loadKeyBindings}
 378      * @return newly created and populated {@code InputMapUIResource}
 379      * @throws IllegalArgumentException if {@code c} is {@code null}
 380      *
 381      * @see #loadKeyBindings
 382      * @see ComponentInputMapUIResource
 383      *
 384      * @since 1.3
 385      */
 386     public static ComponentInputMap makeComponentInputMap(JComponent c,
 387                                                           Object[] keys) {
 388         ComponentInputMap retMap = new ComponentInputMapUIResource(c);
 389         loadKeyBindings(retMap, keys);


 396      * The bindings are supplied as a list of alternating
 397      * {@code keystroke-action key} pairs. The {@code keystroke} is either
 398      * an instance of {@code KeyStroke}, or a {@code String}
 399      * that identifies the {@code KeyStroke} for the binding. Refer
 400      * to {@code KeyStroke.getKeyStroke(String)} for the specific
 401      * format. The {@code action key} part of the pair is the key
 402      * registered in the {@code InputMap} for the {@code KeyStroke}.
 403      * <p>
 404      * The following illustrates loading an {@code InputMap} with two
 405      * {@code key-action} pairs:
 406      * <pre>
 407      *   LookAndFeel.loadKeyBindings(inputMap, new Object[] {
 408      *     "control X", "cut",
 409      *     "control V", "paste"
 410      *   });
 411      * </pre>
 412      * <p>
 413      * Supplying a {@code null} list of bindings ({@code keys}) does not
 414      * change {@code retMap} in any way.
 415      * <p>
 416      * Specifying a {@code null} {@code action key} results in
 417      * removing the {@code keystroke's} entry from the {@code InputMap}.
 418      * A {@code null} {@code keystroke} is ignored.
 419      *
 420      * @param retMap {@code InputMap} to add the {@code key-action}
 421      *               pairs to
 422      * @param keys bindings to add to {@code retMap}
 423      * @throws NullPointerException if {@code keys} is
 424      *         {@code non-null}, not empty, and {@code retMap} is
 425      *         {@code null}
 426      *
 427      * @see KeyStroke#getKeyStroke(String)
 428      * @see InputMap
 429      *
 430      * @since 1.3
 431      */
 432     public static void loadKeyBindings(InputMap retMap, Object[] keys) {
 433         if (keys != null) {
 434             for (int counter = 0, maxCounter = keys.length;
 435                  counter < maxCounter; counter++) {
 436                 Object keyStrokeO = keys[counter++];
 437                 KeyStroke ks = (keyStrokeO instanceof KeyStroke) ?
 438                                 (KeyStroke)keyStrokeO :


 452      * Class.getResourceAsStream(gifFile)}.
 453      * <p>
 454      * This method does not check the arguments in any way. It is
 455      * strongly recommended that {@code non-null} values are supplied else
 456      * exceptions may occur when {@code createValue} is invoked on the
 457      * returned object.
 458      *
 459      * @param baseClass {@code Class} used to load the resource
 460      * @param gifFile path to the image to load
 461      * @return a {@code UIDefaults.LazyValue}; when resolved the
 462      *         {@code LazyValue} loads the specified image
 463      * @see UIDefaults.LazyValue
 464      * @see Icon
 465      * @see Class#getResourceAsStream(String)
 466      */
 467     public static Object makeIcon(final Class<?> baseClass, final String gifFile) {
 468         return SwingUtilities2.makeIcon_Unprivileged(baseClass, baseClass, gifFile);
 469     }
 470 
 471     /**
 472      * Returns the <code>LayoutStyle</code> for this look
 473      * and feel.  This never returns {@code null}.
 474      * <p>
 475      * You generally don't use the <code>LayoutStyle</code> from
 476      * the look and feel, instead use the <code>LayoutStyle</code>
 477      * method <code>getInstance</code>.
 478      *
 479      * @see LayoutStyle#getInstance
 480      * @return the <code>LayoutStyle</code> for this look and feel
 481      * @since 1.6
 482      */
 483     public LayoutStyle getLayoutStyle() {
 484         return DefaultLayoutStyle.getInstance();
 485     }
 486 
 487     /**
 488      * Invoked when the user attempts an invalid operation,
 489      * such as pasting into an uneditable <code>JTextField</code>
 490      * that has focus. The default implementation beeps. Subclasses
 491      * that wish different behavior should override this and provide
 492      * the additional feedback.
 493      *
 494      * @param component the <code>Component</code> the error occurred in,
 495      *                  may be <code>null</code>
 496      *                  indicating the error condition is not directly
 497      *                  associated with a <code>Component</code>
 498      * @since 1.4
 499      */
 500     public void provideErrorFeedback(Component component) {
 501         Toolkit toolkit = null;
 502         if (component != null) {
 503             toolkit = component.getToolkit();
 504         } else {
 505             toolkit = Toolkit.getDefaultToolkit();
 506         }
 507         toolkit.beep();
 508     } // provideErrorFeedback()
 509 
 510     /**
 511      * Returns the value of the specified system desktop property by
 512      * invoking <code>Toolkit.getDefaultToolkit().getDesktopProperty()</code>.
 513      * If the value of the specified property is {@code null},
 514      * {@code fallbackValue} is returned.
 515      *
 516      * @param systemPropertyName the name of the system desktop property being queried
 517      * @param fallbackValue the object to be returned as the value if the system value is null
 518      * @return the current value of the desktop property
 519      *
 520      * @see java.awt.Toolkit#getDesktopProperty
 521      *
 522      * @since 1.4
 523      */
 524     public static Object getDesktopPropertyValue(String systemPropertyName, Object fallbackValue) {
 525         Object value = Toolkit.getDefaultToolkit().getDesktopProperty(systemPropertyName);
 526         if (value == null) {
 527             return fallbackValue;
 528         } else if (value instanceof Color) {
 529             return new ColorUIResource((Color)value);
 530         } else if (value instanceof Font) {
 531             return new FontUIResource((Font)value);
 532         }
 533         return value;
 534     }
 535 
 536     /**
 537      * Returns an <code>Icon</code> with a disabled appearance.
 538      * This method is used to generate a disabled <code>Icon</code> when
 539      * one has not been specified.  For example, if you create a
 540      * <code>JButton</code> and only specify an <code>Icon</code> via
 541      * <code>setIcon</code> this method will be called to generate the
 542      * disabled <code>Icon</code>. If {@code null} is passed as
 543      * <code>icon</code> this method returns {@code null}.
 544      * <p>
 545      * Some look and feels might not render the disabled {@code Icon}, in which
 546      * case they will ignore this.
 547      *
 548      * @param component {@code JComponent} that will display the {@code Icon},
 549      *         may be {@code null}
 550      * @param icon {@code Icon} to generate the disabled icon from
 551      * @return disabled {@code Icon}, or {@code null} if a suitable
 552      *         {@code Icon} can not be generated
 553      * @since 1.5
 554      */
 555     public Icon getDisabledIcon(JComponent component, Icon icon) {
 556         if (icon instanceof ImageIcon) {
 557             return new ImageIconUIResource(GrayFilter.
 558                    createDisabledImage(((ImageIcon)icon).getImage()));
 559         }
 560         return null;
 561     }
 562 
 563     /**
 564      * Returns an <code>Icon</code> for use by disabled
 565      * components that are also selected. This method is used to generate an
 566      * <code>Icon</code> for components that are in both the disabled and
 567      * selected states but do not have a specific <code>Icon</code> for this
 568      * state.  For example, if you create a <code>JButton</code> and only
 569      * specify an <code>Icon</code> via <code>setIcon</code> this method
 570      * will be called to generate the disabled and selected
 571      * <code>Icon</code>. If {@code null} is passed as <code>icon</code> this
 572      * methods returns {@code null}.
 573      * <p>
 574      * Some look and feels might not render the disabled and selected
 575      * {@code Icon}, in which case they will ignore this.
 576      *
 577      * @param component {@code JComponent} that will display the {@code Icon},
 578      *        may be {@code null}
 579      * @param icon {@code Icon} to generate disabled and selected icon from
 580      * @return disabled and selected icon, or {@code null} if a suitable
 581      *         {@code Icon} can not be generated.
 582      * @since 1.5
 583      */
 584     public Icon getDisabledSelectedIcon(JComponent component, Icon icon) {
 585         return getDisabledIcon(component, icon);
 586     }
 587 
 588     /**
 589      * Return a short string that identifies this look and feel, e.g.
 590      * "CDE/Motif".  This string should be appropriate for a menu item.
 591      * Distinct look and feels should have different names, e.g.


 607      * that a LookAndFeel derived from a well known superclass
 608      * that doesn't make any fundamental changes to the look or feel
 609      * shouldn't override this method.
 610      *
 611      * @return identifier for the look and feel
 612      */
 613     public abstract String getID();
 614 
 615 
 616     /**
 617      * Return a one line description of this look and feel implementation,
 618      * e.g. "The CDE/Motif Look and Feel".   This string is intended for
 619      * the user, e.g. in the title of a window or in a ToolTip message.
 620      *
 621      * @return short description for the look and feel
 622      */
 623     public abstract String getDescription();
 624 
 625 
 626     /**
 627      * Returns {@code true} if the <code>LookAndFeel</code> returned
 628      * <code>RootPaneUI</code> instances support providing {@code Window}
 629      * decorations in a <code>JRootPane</code>.
 630      * <p>
 631      * The default implementation returns {@code false}, subclasses that
 632      * support {@code Window} decorations should override this and return
 633      * {@code true}.
 634      *
 635      * @return {@code true} if the {@code RootPaneUI} instances created by
 636      *         this look and feel support client side decorations
 637      * @see JDialog#setDefaultLookAndFeelDecorated
 638      * @see JFrame#setDefaultLookAndFeelDecorated
 639      * @see JRootPane#setWindowDecorationStyle
 640      * @since 1.4
 641      */
 642     public boolean getSupportsWindowDecorations() {
 643         return false;
 644     }
 645 
 646     /**
 647      * If the underlying platform has a "native" look and feel, and
 648      * this is an implementation of it, return {@code true}.  For
 649      * example, when the underlying platform is Solaris running CDE




 274         // includes a class outside of javax.swing, thus we cannot call setUIProperty
 275         // directly.
 276         if (SunToolkit.isInstanceOf(c, "javax.swing.JPasswordField")) {
 277             if (!((JPasswordField)c).customSetUIProperty(propertyName, propertyValue)) {
 278                 c.setUIProperty(propertyName, propertyValue);
 279             }
 280         } else {
 281             c.setUIProperty(propertyName, propertyValue);
 282         }
 283     }
 284 
 285     /**
 286      * Convenience method for building an array of {@code
 287      * KeyBindings}. While this method is not deprecated, developers
 288      * should instead use {@code ActionMap} and {@code InputMap} for
 289      * supplying key bindings.
 290      * <p>
 291      * This method returns an array of {@code KeyBindings}, one for each
 292      * alternating {@code key-action} pair in {@code keyBindingList}.
 293      * A {@code key} can either be a {@code String} in the format
 294      * specified by the {@code KeyStroke.getKeyStroke} method, or
 295      * a {@code KeyStroke}. The {@code action} part of the pair is a
 296      * {@code String} that corresponds to the name of the {@code
 297      * Action}.
 298      * <p>
 299      * The following example illustrates creating a {@code KeyBinding} array
 300      * from six alternating {@code key-action} pairs:
 301      * <pre>
 302      *  JTextComponent.KeyBinding[] multilineBindings = makeKeyBindings( new Object[] {
 303      *          "UP", DefaultEditorKit.upAction,
 304      *        "DOWN", DefaultEditorKit.downAction,
 305      *     "PAGE_UP", DefaultEditorKit.pageUpAction,
 306      *   "PAGE_DOWN", DefaultEditorKit.pageDownAction,
 307      *       "ENTER", DefaultEditorKit.insertBreakAction,
 308      *         "TAB", DefaultEditorKit.insertTabAction
 309      *  });
 310      * </pre>
 311      * If {@code keyBindingList's} length is odd, the last element is
 312      * ignored.
 313      * <p>
 314      * Supplying a {@code null} value for either the {@code key} or


 329      * @see InputMap
 330      * @see KeyStroke#getKeyStroke
 331      */
 332     public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList)
 333     {
 334         JTextComponent.KeyBinding[] rv = new JTextComponent.KeyBinding[keyBindingList.length / 2];
 335 
 336         for(int i = 0; i < rv.length; i ++) {
 337             Object o = keyBindingList[2 * i];
 338             KeyStroke keystroke = (o instanceof KeyStroke)
 339                 ? (KeyStroke) o
 340                 : KeyStroke.getKeyStroke((String) o);
 341             String action = (String) keyBindingList[2 * i + 1];
 342             rv[i] = new JTextComponent.KeyBinding(keystroke, action);
 343         }
 344 
 345         return rv;
 346     }
 347 
 348     /**
 349      * Creates a {@code InputMapUIResource} from {@code keys}. This is
 350      * a convenience method for creating a new {@code InputMapUIResource},
 351      * invoking {@code loadKeyBindings(map, keys)}, and returning the
 352      * {@code InputMapUIResource}.
 353      *
 354      * @param keys alternating pairs of {@code keystroke-action key}
 355      *        pairs as described in {@link #loadKeyBindings}
 356      * @return newly created and populated {@code InputMapUIResource}
 357      * @see #loadKeyBindings
 358      *
 359      * @since 1.3
 360      */
 361     public static InputMap makeInputMap(Object[] keys) {
 362         InputMap retMap = new InputMapUIResource();
 363         loadKeyBindings(retMap, keys);
 364         return retMap;
 365     }
 366 
 367     /**
 368      * Creates a {@code ComponentInputMapUIResource} from
 369      * {@code keys}. This is a convenience method for creating a
 370      * new {@code ComponentInputMapUIResource}, invoking {@code
 371      * loadKeyBindings(map, keys)}, and returning the {@code
 372      * ComponentInputMapUIResource}.
 373      *
 374      * @param c component to create the {@code ComponentInputMapUIResource}
 375      *          with
 376      * @param keys alternating pairs of {@code keystroke-action key}
 377      *        pairs as described in {@link #loadKeyBindings}
 378      * @return newly created and populated {@code InputMapUIResource}
 379      * @throws IllegalArgumentException if {@code c} is {@code null}
 380      *
 381      * @see #loadKeyBindings
 382      * @see ComponentInputMapUIResource
 383      *
 384      * @since 1.3
 385      */
 386     public static ComponentInputMap makeComponentInputMap(JComponent c,
 387                                                           Object[] keys) {
 388         ComponentInputMap retMap = new ComponentInputMapUIResource(c);
 389         loadKeyBindings(retMap, keys);


 396      * The bindings are supplied as a list of alternating
 397      * {@code keystroke-action key} pairs. The {@code keystroke} is either
 398      * an instance of {@code KeyStroke}, or a {@code String}
 399      * that identifies the {@code KeyStroke} for the binding. Refer
 400      * to {@code KeyStroke.getKeyStroke(String)} for the specific
 401      * format. The {@code action key} part of the pair is the key
 402      * registered in the {@code InputMap} for the {@code KeyStroke}.
 403      * <p>
 404      * The following illustrates loading an {@code InputMap} with two
 405      * {@code key-action} pairs:
 406      * <pre>
 407      *   LookAndFeel.loadKeyBindings(inputMap, new Object[] {
 408      *     "control X", "cut",
 409      *     "control V", "paste"
 410      *   });
 411      * </pre>
 412      * <p>
 413      * Supplying a {@code null} list of bindings ({@code keys}) does not
 414      * change {@code retMap} in any way.
 415      * <p>
 416      * Specifying a {@code null action key} results in
 417      * removing the {@code keystroke's} entry from the {@code InputMap}.
 418      * A {@code null keystroke} is ignored.
 419      *
 420      * @param retMap {@code InputMap} to add the {@code key-action}
 421      *               pairs to
 422      * @param keys bindings to add to {@code retMap}
 423      * @throws NullPointerException if {@code keys} is
 424      *         {@code non-null}, not empty, and {@code retMap} is
 425      *         {@code null}
 426      *
 427      * @see KeyStroke#getKeyStroke(String)
 428      * @see InputMap
 429      *
 430      * @since 1.3
 431      */
 432     public static void loadKeyBindings(InputMap retMap, Object[] keys) {
 433         if (keys != null) {
 434             for (int counter = 0, maxCounter = keys.length;
 435                  counter < maxCounter; counter++) {
 436                 Object keyStrokeO = keys[counter++];
 437                 KeyStroke ks = (keyStrokeO instanceof KeyStroke) ?
 438                                 (KeyStroke)keyStrokeO :


 452      * Class.getResourceAsStream(gifFile)}.
 453      * <p>
 454      * This method does not check the arguments in any way. It is
 455      * strongly recommended that {@code non-null} values are supplied else
 456      * exceptions may occur when {@code createValue} is invoked on the
 457      * returned object.
 458      *
 459      * @param baseClass {@code Class} used to load the resource
 460      * @param gifFile path to the image to load
 461      * @return a {@code UIDefaults.LazyValue}; when resolved the
 462      *         {@code LazyValue} loads the specified image
 463      * @see UIDefaults.LazyValue
 464      * @see Icon
 465      * @see Class#getResourceAsStream(String)
 466      */
 467     public static Object makeIcon(final Class<?> baseClass, final String gifFile) {
 468         return SwingUtilities2.makeIcon_Unprivileged(baseClass, baseClass, gifFile);
 469     }
 470 
 471     /**
 472      * Returns the {@code LayoutStyle} for this look
 473      * and feel.  This never returns {@code null}.
 474      * <p>
 475      * You generally don't use the {@code LayoutStyle} from
 476      * the look and feel, instead use the {@code LayoutStyle}
 477      * method {@code getInstance}.
 478      *
 479      * @see LayoutStyle#getInstance
 480      * @return the {@code LayoutStyle} for this look and feel
 481      * @since 1.6
 482      */
 483     public LayoutStyle getLayoutStyle() {
 484         return DefaultLayoutStyle.getInstance();
 485     }
 486 
 487     /**
 488      * Invoked when the user attempts an invalid operation,
 489      * such as pasting into an uneditable {@code JTextField}
 490      * that has focus. The default implementation beeps. Subclasses
 491      * that wish different behavior should override this and provide
 492      * the additional feedback.
 493      *
 494      * @param component the {@code Component} the error occurred in,
 495      *                  may be {@code null}
 496      *                  indicating the error condition is not directly
 497      *                  associated with a {@code Component}
 498      * @since 1.4
 499      */
 500     public void provideErrorFeedback(Component component) {
 501         Toolkit toolkit = null;
 502         if (component != null) {
 503             toolkit = component.getToolkit();
 504         } else {
 505             toolkit = Toolkit.getDefaultToolkit();
 506         }
 507         toolkit.beep();
 508     } // provideErrorFeedback()
 509 
 510     /**
 511      * Returns the value of the specified system desktop property by
 512      * invoking {@code Toolkit.getDefaultToolkit().getDesktopProperty()}.
 513      * If the value of the specified property is {@code null},
 514      * {@code fallbackValue} is returned.
 515      *
 516      * @param systemPropertyName the name of the system desktop property being queried
 517      * @param fallbackValue the object to be returned as the value if the system value is null
 518      * @return the current value of the desktop property
 519      *
 520      * @see java.awt.Toolkit#getDesktopProperty
 521      *
 522      * @since 1.4
 523      */
 524     public static Object getDesktopPropertyValue(String systemPropertyName, Object fallbackValue) {
 525         Object value = Toolkit.getDefaultToolkit().getDesktopProperty(systemPropertyName);
 526         if (value == null) {
 527             return fallbackValue;
 528         } else if (value instanceof Color) {
 529             return new ColorUIResource((Color)value);
 530         } else if (value instanceof Font) {
 531             return new FontUIResource((Font)value);
 532         }
 533         return value;
 534     }
 535 
 536     /**
 537      * Returns an {@code Icon} with a disabled appearance.
 538      * This method is used to generate a disabled {@code Icon} when
 539      * one has not been specified.  For example, if you create a
 540      * {@code JButton} and only specify an {@code Icon} via
 541      * {@code setIcon} this method will be called to generate the
 542      * disabled {@code Icon}. If {@code null} is passed as
 543      * {@code icon} this method returns {@code null}.
 544      * <p>
 545      * Some look and feels might not render the disabled {@code Icon}, in which
 546      * case they will ignore this.
 547      *
 548      * @param component {@code JComponent} that will display the {@code Icon},
 549      *         may be {@code null}
 550      * @param icon {@code Icon} to generate the disabled icon from
 551      * @return disabled {@code Icon}, or {@code null} if a suitable
 552      *         {@code Icon} can not be generated
 553      * @since 1.5
 554      */
 555     public Icon getDisabledIcon(JComponent component, Icon icon) {
 556         if (icon instanceof ImageIcon) {
 557             return new ImageIconUIResource(GrayFilter.
 558                    createDisabledImage(((ImageIcon)icon).getImage()));
 559         }
 560         return null;
 561     }
 562 
 563     /**
 564      * Returns an {@code Icon} for use by disabled
 565      * components that are also selected. This method is used to generate an
 566      * {@code Icon} for components that are in both the disabled and
 567      * selected states but do not have a specific {@code Icon} for this
 568      * state.  For example, if you create a {@code JButton} and only
 569      * specify an {@code Icon} via {@code setIcon} this method
 570      * will be called to generate the disabled and selected
 571      * {@code Icon}. If {@code null} is passed as {@code icon} this
 572      * methods returns {@code null}.
 573      * <p>
 574      * Some look and feels might not render the disabled and selected
 575      * {@code Icon}, in which case they will ignore this.
 576      *
 577      * @param component {@code JComponent} that will display the {@code Icon},
 578      *        may be {@code null}
 579      * @param icon {@code Icon} to generate disabled and selected icon from
 580      * @return disabled and selected icon, or {@code null} if a suitable
 581      *         {@code Icon} can not be generated.
 582      * @since 1.5
 583      */
 584     public Icon getDisabledSelectedIcon(JComponent component, Icon icon) {
 585         return getDisabledIcon(component, icon);
 586     }
 587 
 588     /**
 589      * Return a short string that identifies this look and feel, e.g.
 590      * "CDE/Motif".  This string should be appropriate for a menu item.
 591      * Distinct look and feels should have different names, e.g.


 607      * that a LookAndFeel derived from a well known superclass
 608      * that doesn't make any fundamental changes to the look or feel
 609      * shouldn't override this method.
 610      *
 611      * @return identifier for the look and feel
 612      */
 613     public abstract String getID();
 614 
 615 
 616     /**
 617      * Return a one line description of this look and feel implementation,
 618      * e.g. "The CDE/Motif Look and Feel".   This string is intended for
 619      * the user, e.g. in the title of a window or in a ToolTip message.
 620      *
 621      * @return short description for the look and feel
 622      */
 623     public abstract String getDescription();
 624 
 625 
 626     /**
 627      * Returns {@code true} if the {@code LookAndFeel} returned
 628      * {@code RootPaneUI} instances support providing {@code Window}
 629      * decorations in a {@code JRootPane}.
 630      * <p>
 631      * The default implementation returns {@code false}, subclasses that
 632      * support {@code Window} decorations should override this and return
 633      * {@code true}.
 634      *
 635      * @return {@code true} if the {@code RootPaneUI} instances created by
 636      *         this look and feel support client side decorations
 637      * @see JDialog#setDefaultLookAndFeelDecorated
 638      * @see JFrame#setDefaultLookAndFeelDecorated
 639      * @see JRootPane#setWindowDecorationStyle
 640      * @since 1.4
 641      */
 642     public boolean getSupportsWindowDecorations() {
 643         return false;
 644     }
 645 
 646     /**
 647      * If the underlying platform has a "native" look and feel, and
 648      * this is an implementation of it, return {@code true}.  For
 649      * example, when the underlying platform is Solaris running CDE


< prev index next >