IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
 
[Sommaire]  [Top 50]  [F.A.Q.]  [ Java SE ]  [ Java EE ]  [Javadoc standard]  [Contact]
[ 1.4.2 ]  [ 5.0 ]  [ 6.0
Rechercher   
Dans
Options   sensible à la casse
étendre la recherche aux descriptions
Préférences
fr en 
 
Moteurs de recherche
JavaTM 2 Platform Std. Ed. v1.5.0

javax.swing.plaf.metal
Class MetalLookAndFeel

java.lang.Object
  extended by javax.swing.LookAndFeel
      extended by javax.swing.plaf.basic.BasicLookAndFeel
          extended by javax.swing.plaf.metal.MetalLookAndFeel
All Implemented Interfaces:
Serializable

public class MetalLookAndFeel
extends BasicLookAndFeel

Implements the Java look and feel (codename: Metal).

By default metal uses bold fonts for many controls. To make all controls (with the exception of the internal frame title bars and client decorated frame title bars) use plain fonts you can do either of the following:

  • Set the system property swing.boldMetal to false. For example, java -Dswing.boldMetal=false MyApp.
  • Set the defaults property swing.boldMetal to Boolean.FALSE. For example: UIManager.put("swing.boldMetal", Boolean.FALSE);
The defaults property swing.boldMetal, if set, takes precendence over the system property of the same name. After setting this defaults property you need to re-install the MetalLookAndFeel, as well as update the UI of any previously created widgets. Otherwise the results are undefined. These lines of code show you how to accomplish this:
   // turn off bold fonts
   UIManager.put("swing.boldMetal", Boolean.FALSE);

   // re-install the Metal Look and Feel
   UIManager.setLookAndFeel(new MetalLookAndFeel());

   // only needed to update existing widgets
   SwingUtilities.updateComponentTreeUI(rootComponent);
 

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.


Constructor Summary
MetalLookAndFeel()
           
 
Method Summary
protected  void createDefaultTheme()
           
static ColorUIResource getAcceleratorForeground()
           
static ColorUIResource getAcceleratorSelectedForeground()
           
static ColorUIResource getBlack()
           
static ColorUIResource getControl()
           
static ColorUIResource getControlDarkShadow()
           
static ColorUIResource getControlDisabled()
           
static ColorUIResource getControlHighlight()
           
static ColorUIResource getControlInfo()
           
static ColorUIResource getControlShadow()
           
static ColorUIResource getControlTextColor()
           
static FontUIResource getControlTextFont()
           
static MetalTheme getCurrentTheme()
          Return the theme currently being used by MetalLookAndFeel.
 UIDefaults getDefaults()
          This method is called once by UIManager.setLookAndFeel to create the look and feel specific defaults table.
 String getDescription()
          Return a one line description of this look and feel implementation, e.g.
static ColorUIResource getDesktopColor()
           
 Icon getDisabledIcon(JComponent component, Icon icon)
          Returns an Icon with a disabled appearance.
 Icon getDisabledSelectedIcon(JComponent component, Icon icon)
          Returns an Icon for use by disabled components that are also selected.
static ColorUIResource getFocusColor()
           
static ColorUIResource getHighlightedTextColor()
           
 String getID()
          Return a string that identifies this look and feel.
static ColorUIResource getInactiveControlTextColor()
           
static ColorUIResource getInactiveSystemTextColor()
           
static ColorUIResource getMenuBackground()
           
static ColorUIResource getMenuDisabledForeground()
           
static ColorUIResource getMenuForeground()
           
static ColorUIResource getMenuSelectedBackground()
           
static ColorUIResource getMenuSelectedForeground()
           
static FontUIResource getMenuTextFont()
           
 String getName()
          Return a short string that identifies this look and feel, e.g.
static ColorUIResource getPrimaryControl()
           
static ColorUIResource getPrimaryControlDarkShadow()
           
static ColorUIResource getPrimaryControlHighlight()
           
static ColorUIResource getPrimaryControlInfo()
           
static ColorUIResource getPrimaryControlShadow()
           
static ColorUIResource getSeparatorBackground()
           
static ColorUIResource getSeparatorForeground()
           
static FontUIResource getSubTextFont()
           
 boolean getSupportsWindowDecorations()
          Returns true if the LookAndFeel returned RootPaneUI instances support providing Window decorations in a JRootPane.
static ColorUIResource getSystemTextColor()
           
static FontUIResource getSystemTextFont()
           
static ColorUIResource getTextHighlightColor()
           
static ColorUIResource getUserTextColor()
           
static FontUIResource getUserTextFont()
           
static ColorUIResource getWhite()
           
static ColorUIResource getWindowBackground()
           
static ColorUIResource getWindowTitleBackground()
           
static FontUIResource getWindowTitleFont()
           
static ColorUIResource getWindowTitleForeground()
           
static ColorUIResource getWindowTitleInactiveBackground()
           
static ColorUIResource getWindowTitleInactiveForeground()
           
protected  void initClassDefaults(UIDefaults table)
          Creates the mapping from UI class IDs to ComponentUI classes, putting the ID-ComponentUI pairs in the passed-in defaults table.
protected  void initComponentDefaults(UIDefaults table)
           
protected  void initSystemColorDefaults(UIDefaults table)
          Load the SystemColors into the defaults table.
 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(Component component)
           Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus.
static void setCurrentTheme(MetalTheme theme)
          Set the theme to be used by MetalLookAndFeel.
 
Methods inherited from class javax.swing.plaf.basic.BasicLookAndFeel
createAudioAction, getAudioActionMap, initialize, loadSystemColors, playSound, uninitialize
 
Methods inherited from class javax.swing.LookAndFeel
getDesktopPropertyValue, 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
 

Constructor Detail

MetalLookAndFeel

public MetalLookAndFeel()
Method Detail

getName

public String getName()
Description copied from class: LookAndFeel
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 LookAndFeel

getID

public String getID()
Description copied from class: LookAndFeel
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 LookAndFeel

getDescription

public String getDescription()
Description copied from class: LookAndFeel
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 LookAndFeel

isNativeLookAndFeel

public boolean isNativeLookAndFeel()
Description copied from class: LookAndFeel
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 LookAndFeel

isSupportedLookAndFeel

public boolean isSupportedLookAndFeel()
Description copied from class: LookAndFeel
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 LookAndFeel
See Also:
UIManager.setLookAndFeel(javax.swing.LookAndFeel)

getSupportsWindowDecorations

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

This implementation returns true, since it does support providing these border and window title pane decorations.

Overrides:
getSupportsWindowDecorations in class 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)

initClassDefaults

protected void initClassDefaults(UIDefaults table)
Creates the mapping from UI class IDs to ComponentUI classes, putting the ID-ComponentUI pairs in the passed-in defaults table. Each JComponent class specifies its own UI class ID string. For example, JButton has the UI class ID "ButtonUI", which this method maps to "javax.swing.plaf.metal.MetalButtonUI".

Overrides:
initClassDefaults in class BasicLookAndFeel
See Also:
BasicLookAndFeel.getDefaults(), JComponent.getUIClassID()

initSystemColorDefaults

protected void initSystemColorDefaults(UIDefaults table)
Load the SystemColors into the defaults table. The keys for SystemColor defaults are the same as the names of the public fields in SystemColor.

Overrides:
initSystemColorDefaults in class BasicLookAndFeel

initComponentDefaults

protected void initComponentDefaults(UIDefaults table)
Overrides:
initComponentDefaults in class BasicLookAndFeel

createDefaultTheme

protected void createDefaultTheme()

getDefaults

public UIDefaults getDefaults()
Description copied from class: LookAndFeel
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 BasicLookAndFeel
See Also:
LookAndFeel.initialize(), LookAndFeel.uninitialize(), UIManager.setLookAndFeel(javax.swing.LookAndFeel)

provideErrorFeedback

public void provideErrorFeedback(Component component)

Invoked when the user attempts an invalid operation, such as pasting into an uneditable JTextField that has focus.

If the user has enabled visual error indication on the desktop, this method will flash the caption bar of the active window. The user can also set the property awt.visualbell=true to achieve the same results.

Overrides:
provideErrorFeedback in class LookAndFeel
Parameters:
component - Component the error occured in, may be null indicating the error condition is not directly associated with a Component.
See Also:
LookAndFeel.provideErrorFeedback(java.awt.Component)

setCurrentTheme

public static void setCurrentTheme(MetalTheme theme)
Set the theme to be used by MetalLookAndFeel. This may not be null.
After setting the theme, you need to re-install the MetalLookAndFeel, as well as update the UI of any previously created widgets. Otherwise the results are undefined. These lines of code show you how to accomplish this:
   // turn off bold fonts
   MetalLookAndFeel.setCurrentTheme(theme);

   // re-install the Metal Look and Feel
   UIManager.setLookAndFeel(new MetalLookAndFeel());

   // only needed to update existing widgets
   SwingUtilities.updateComponentTreeUI(rootComponent);
 

Parameters:
theme - the theme to be used, non-null
Throws:
NullPointerException - if given a null parameter
See Also:
getCurrentTheme()

getCurrentTheme

public static MetalTheme getCurrentTheme()
Return the theme currently being used by MetalLookAndFeel. This will always be non-null, as it will set the current theme if one hasn't been set already.

Returns:
the current theme
Since:
1.5
See Also:
setCurrentTheme(javax.swing.plaf.metal.MetalTheme)

getDisabledIcon

public Icon getDisabledIcon(JComponent component,
                            Icon icon)
Returns an Icon with a disabled appearance. This method is used to generate a disabled Icon when one has not been specified. For example, if you create a JButton and only specify an Icon via setIcon this method will be called to generate the disabled Icon. If null is passed as icon this method returns null.

Some look and feels might not render the disabled Icon, in which case they will ignore this.

Overrides:
getDisabledIcon in class LookAndFeel
Parameters:
component - JComponent that will display the Icon, may be null
icon - Icon to generate disable icon from.
Returns:
Disabled icon, or null if a suitable Icon can not be generated.
Since:
1.5

getDisabledSelectedIcon

public Icon getDisabledSelectedIcon(JComponent component,
                                    Icon icon)
Returns an Icon for use by disabled components that are also selected. This method is used to generate an Icon for components that are in both the disabled and selected states but do not have a specific Icon for this state. For example, if you create a JButton and only specify an Icon via setIcon this method will be called to generate the disabled and selected Icon. If null is passed as icon this method returns null.

Some look and feels might not render the disabled and selected Icon, in which case they will ignore this.

Overrides:
getDisabledSelectedIcon in class LookAndFeel
Parameters:
component - JComponent that will display the Icon, may be null
icon - Icon to generate disabled and selected icon from.
Returns:
Disabled and Selected icon, or null if a suitable Icon can not be generated.
Since:
1.5

getControlTextFont

public static FontUIResource getControlTextFont()

getSystemTextFont

public static FontUIResource getSystemTextFont()

getUserTextFont

public static FontUIResource getUserTextFont()

getMenuTextFont

public static FontUIResource getMenuTextFont()

getWindowTitleFont

public static FontUIResource getWindowTitleFont()

getSubTextFont

public static FontUIResource getSubTextFont()

getDesktopColor

public static ColorUIResource getDesktopColor()

getFocusColor

public static ColorUIResource getFocusColor()

getWhite

public static ColorUIResource getWhite()

getBlack

public static ColorUIResource getBlack()

getControl

public static ColorUIResource getControl()

getControlShadow

public static ColorUIResource getControlShadow()

getControlDarkShadow

public static ColorUIResource getControlDarkShadow()

getControlInfo

public static ColorUIResource getControlInfo()

getControlHighlight

public static ColorUIResource getControlHighlight()

getControlDisabled

public static ColorUIResource getControlDisabled()

getPrimaryControl

public static ColorUIResource getPrimaryControl()

getPrimaryControlShadow

public static ColorUIResource getPrimaryControlShadow()

getPrimaryControlDarkShadow

public static ColorUIResource getPrimaryControlDarkShadow()

getPrimaryControlInfo

public static ColorUIResource getPrimaryControlInfo()

getPrimaryControlHighlight

public static ColorUIResource getPrimaryControlHighlight()

getSystemTextColor

public static ColorUIResource getSystemTextColor()

getControlTextColor

public static ColorUIResource getControlTextColor()

getInactiveControlTextColor

public static ColorUIResource getInactiveControlTextColor()

getInactiveSystemTextColor

public static ColorUIResource getInactiveSystemTextColor()

getUserTextColor

public static ColorUIResource getUserTextColor()

getTextHighlightColor

public static ColorUIResource getTextHighlightColor()

getHighlightedTextColor

public static ColorUIResource getHighlightedTextColor()

getWindowBackground

public static ColorUIResource getWindowBackground()

getWindowTitleBackground

public static ColorUIResource getWindowTitleBackground()

getWindowTitleForeground

public static ColorUIResource getWindowTitleForeground()

getWindowTitleInactiveBackground

public static ColorUIResource getWindowTitleInactiveBackground()

getWindowTitleInactiveForeground

public static ColorUIResource getWindowTitleInactiveForeground()

getMenuBackground

public static ColorUIResource getMenuBackground()

getMenuForeground

public static ColorUIResource getMenuForeground()

getMenuSelectedBackground

public static ColorUIResource getMenuSelectedBackground()

getMenuSelectedForeground

public static ColorUIResource getMenuSelectedForeground()

getMenuDisabledForeground

public static ColorUIResource getMenuDisabledForeground()

getSeparatorBackground

public static ColorUIResource getSeparatorBackground()

getSeparatorForeground

public static ColorUIResource getSeparatorForeground()

getAcceleratorForeground

public static ColorUIResource getAcceleratorForeground()

getAcceleratorSelectedForeground

public static ColorUIResource getAcceleratorSelectedForeground()

Copyright 2003 Sun Microsystems, Inc. All rights reserved