Quaqua 7.4.2 2011-07-05

ch.randelshofer.quaqua
Class LookAndFeelProxy

java.lang.Object
  extended by javax.swing.LookAndFeel
      extended by javax.swing.plaf.basic.BasicLookAndFeel
          extended by ch.randelshofer.quaqua.LookAndFeelProxy
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
QuaquaLeopardFileChooserLAF, QuaquaLookAndFeel, QuaquaPantherFileChooserLAF

public class LookAndFeelProxy
extends javax.swing.plaf.basic.BasicLookAndFeel

A proxy for LookAndFeel objects. This class enables us to override the behaviour of LookAndFeel objects whithout subclassing them.

Note this class extends BasicLookAndFeel instead of LookAndFeel. This is because some UI classes derived from the Basic LAF don't work if they can't cast the current LookAndFeel to BasicLookAndFeel.

Version:
$Id: LookAndFeelProxy.java 361 2010-11-21 11:19:20Z wrandelshofer $
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Immensee, Switzerland
See Also:
Serialized Form

Field Summary
protected  javax.swing.LookAndFeel target
          The target LookAndFeel.
 
Constructor Summary
protected LookAndFeelProxy()
          Creates a new instance with a null target.
  LookAndFeelProxy(javax.swing.LookAndFeel target)
          Creates a new instance which proxies the supplied target.
 
Method Summary
 javax.swing.UIDefaults getDefaults()
          This method is called once by UIManager.setLookAndFeel to create the look and feel specific defaults table.
 java.lang.String getDescription()
          Return a one line description of this look and feel implementation, e.g.
 java.lang.String getID()
          Return a string that identifies this look and feel.
 javax.swing.LayoutStyle getLayoutStyle()
           
 java.lang.String getName()
          Return a short string that identifies this look and feel, e.g.
 boolean getSupportsWindowDecorations()
          Returns true if the LookAndFeel returned RootPaneUI instances support providing Window decorations in a JRootPane.
 void initialize()
          UIManager.setLookAndFeel calls this method before the first call (and typically the only call) to getDefaults().
 boolean isNativeLookAndFeel()
          If the underlying platform has a "native" look and feel, and this is an implementation of it, return true.
 boolean isSupportedLookAndFeel()
          Return true if the underlying platform supports and or permits this look and feel.
 void provideErrorFeedback(java.awt.Component component)
          Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus.
protected  void setTarget(javax.swing.LookAndFeel target)
          Sets the target of this proxy.
 void uninitialize()
          UIManager.setLookAndFeel calls this method just before we're replaced by a new default look and feel.
 
Methods inherited from class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, initClassDefaults, initComponentDefaults, initSystemColorDefaults, loadSystemColors, playSound
 
Methods inherited from class javax.swing.LookAndFeel
getDesktopPropertyValue, getDisabledIcon, getDisabledSelectedIcon, installBorder, installColors, installColorsAndFont, installProperty, loadKeyBindings, makeComponentInputMap, makeIcon, makeInputMap, makeKeyBindings, toString, uninstallBorder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

target

protected javax.swing.LookAndFeel target
The target LookAndFeel.

Constructor Detail

LookAndFeelProxy

public LookAndFeelProxy(javax.swing.LookAndFeel target)
Creates a new instance which proxies the supplied target.


LookAndFeelProxy

protected LookAndFeelProxy()
Creates a new instance with a null target.

Method Detail

setTarget

protected void setTarget(javax.swing.LookAndFeel target)
Sets the target of this proxy.


getDescription

public java.lang.String getDescription()
Return a one line description of this look and feel implementation, e.g. "The CDE/Motif Look and Feel". This string is intended for the user, e.g. in the title of a window or in a ToolTip message.

Specified by:
getDescription in class javax.swing.LookAndFeel

getID

public java.lang.String getID()
Return a string that identifies this look and feel. This string will be used by applications/services that want to recognize well known look and feel implementations. Presently the well known names are "Motif", "Windows", "Mac", "Metal". Note that a LookAndFeel derived from a well known superclass that doesn't make any fundamental changes to the look or feel shouldn't override this method.

Specified by:
getID in class javax.swing.LookAndFeel

getName

public java.lang.String getName()
Return a short string that identifies this look and feel, e.g. "CDE/Motif". This string should be appropriate for a menu item. Distinct look and feels should have different names, e.g. a subclass of MotifLookAndFeel that changes the way a few components are rendered should be called "CDE/Motif My Way"; something that would be useful to a user trying to select a L&F from a list of names.

Specified by:
getName in class javax.swing.LookAndFeel

isNativeLookAndFeel

public boolean isNativeLookAndFeel()
If the underlying platform has a "native" look and feel, and this is an implementation of it, return true. For example a CDE/Motif look and implementation would return true when the underlying platform was Solaris.

Specified by:
isNativeLookAndFeel in class javax.swing.LookAndFeel

isSupportedLookAndFeel

public boolean isSupportedLookAndFeel()
Return true if the underlying platform supports and or permits this look and feel. This method returns false if the look and feel depends on special resources or legal agreements that aren't defined for the current platform.

Specified by:
isSupportedLookAndFeel in class javax.swing.LookAndFeel
See Also:
UIManager.setLookAndFeel(javax.swing.LookAndFeel)

provideErrorFeedback

public void provideErrorFeedback(java.awt.Component component)
Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus. The default implementation beeps. Subclasses that wish different behavior should override this and provide the additional feedback.

Overrides:
provideErrorFeedback in class javax.swing.LookAndFeel
Parameters:
component - Component the error occured in, may be null indicating the error condition is not directly associated with a Component.

getSupportsWindowDecorations

public boolean getSupportsWindowDecorations()
Returns true if the LookAndFeel returned RootPaneUI instances support providing Window decorations in a JRootPane.

The default implementation returns false, subclasses that support Window decorations should override this and return true.

Overrides:
getSupportsWindowDecorations in class javax.swing.LookAndFeel
Returns:
True if the RootPaneUI instances created support client side decorations
Since:
1.4
See Also:
JDialog.setDefaultLookAndFeelDecorated(boolean), JFrame.setDefaultLookAndFeelDecorated(boolean), JRootPane.setWindowDecorationStyle(int)

initialize

public void initialize()
UIManager.setLookAndFeel calls this method before the first call (and typically the only call) to getDefaults(). Subclasses should do any one-time setup they need here, rather than in a static initializer, because look and feel class objects may be loaded just to discover that isSupportedLookAndFeel() returns false.

Overrides:
initialize in class javax.swing.plaf.basic.BasicLookAndFeel
See Also:
uninitialize(), UIManager.setLookAndFeel(javax.swing.LookAndFeel)

uninitialize

public void uninitialize()
UIManager.setLookAndFeel calls this method just before we're replaced by a new default look and feel. Subclasses may choose to free up some resources here.

Overrides:
uninitialize in class javax.swing.plaf.basic.BasicLookAndFeel
See Also:
initialize()

getDefaults

public javax.swing.UIDefaults getDefaults()
This method is called once by UIManager.setLookAndFeel to create the look and feel specific defaults table. Other applications, for example an application builder, may also call this method.

Overrides:
getDefaults in class javax.swing.plaf.basic.BasicLookAndFeel
See Also:
initialize(), uninitialize(), UIManager.setLookAndFeel(javax.swing.LookAndFeel)

getLayoutStyle

public javax.swing.LayoutStyle getLayoutStyle()
Overrides:
getLayoutStyle in class javax.swing.LookAndFeel

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.