Nimbus look and feel in java

Class NimbusLookAndFeel

Get a derived color, derived colors are shared instances and is color value will change when its parent UIDefault color changes.

Returns whether or not the UIs should update their SynthStyles from the SynthStyleFactory when the ancestor of the JComponent changes.

Methods declared in class javax.swing.plaf.synth.SynthLookAndFeel

Methods declared in class javax.swing.plaf.basic.BasicLookAndFeel

Methods declared in class javax.swing.LookAndFeel

Methods declared in class java.lang.Object

Constructor Details

NimbusLookAndFeel

Method Details

initialize

uninitialize

getStyle

Gets the style associated with the given component and region. This will never return null. If an appropriate component and region cannot be determined, then a default style is returned.

getName

Return a short string that identifies this look and feel. This String will be the unquoted String «Nimbus».

getID

Return a string that identifies this look and feel. This String will be the unquoted String «Nimbus».

getDescription

shouldUpdateStyleOnAncestorChanged

Returns whether or not the UIs should update their SynthStyles from the SynthStyleFactory when the ancestor of the JComponent changes. A subclass that provided a SynthStyleFactory that based the return value from getStyle off the containment hierarchy would override this method to return true.

shouldUpdateStyleOnEvent

register

Registers a third party component with the NimbusLookAndFeel. Regions represent Components and areas within Components that act as independent painting areas. Once registered with the NimbusLookAndFeel, NimbusStyles for these Regions can be retrieved via the getStyle method. The NimbusLookAndFeel uses a standard naming scheme for entries in the UIDefaults table. The key for each property, state, painter, and other default registered in UIDefaults for a specific Region will begin with the specified prefix For example, suppose I had a component named JFoo. Suppose I then registered this component with the NimbusLookAndFeel in this manner:

 laf.register(NimbusFooUI.FOO_REGION, "Foo"); 

In this case, I could then register properties for this component with UIDefaults in the following manner:

 UIManager.put("Foo.background", new ColorUIResource(Color.BLACK)); UIManager.put("Foo.Enabled.backgroundPainter", new FooBackgroundPainter()); 

It is also possible to register a named component with Nimbus. For example, suppose you wanted to style the background of a JPanel named «MyPanel» differently from other JPanels. You could accomplish this by doing the following:

 laf.register(Region.PANEL, "\"MyPanel\""); UIManager.put("\"MyPanel\".background", new ColorUIResource(Color.RED)); 

getDerivedColor

public Color getDerivedColor (String uiDefaultParentName, float hOffset, float sOffset, float bOffset, int aOffset, boolean uiResource)

Читайте также:  Conditions We Treat

Get a derived color, derived colors are shared instances and is color value will change when its parent UIDefault color changes.

getDerivedColor

protected final Color getDerivedColor (Color color1, Color color2, float midPoint, boolean uiResource)

getDerivedColor

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Источник

Nimbus look and feel in java

Get a derived color, derived colors are shared instances and is color value will change when its parent UIDefault color changes.

Returns whether or not the UIs should update their SynthStyles from the SynthStyleFactory when the ancestor of the JComponent changes.

Methods declared in class javax.swing.plaf.synth.SynthLookAndFeel

Methods declared in class javax.swing.plaf.basic.BasicLookAndFeel

Methods declared in class javax.swing.LookAndFeel

Methods declared in class java.lang.Object

Constructor Detail

NimbusLookAndFeel

Method Detail

initialize

uninitialize

getStyle

public static NimbusStyle getStyle​(JComponent c, Region r)

Gets the style associated with the given component and region. This will never return null. If an appropriate component and region cannot be determined, then a default style is returned.

getName

Return a short string that identifies this look and feel. This String will be the unquoted String «Nimbus».

getID

Return a string that identifies this look and feel. This String will be the unquoted String «Nimbus».

Читайте также:  Пример DIV, перекрывающего весь экран

getDescription

shouldUpdateStyleOnAncestorChanged

public boolean shouldUpdateStyleOnAncestorChanged()

Returns whether or not the UIs should update their SynthStyles from the SynthStyleFactory when the ancestor of the JComponent changes. A subclass that provided a SynthStyleFactory that based the return value from getStyle off the containment hierarchy would override this method to return true.

shouldUpdateStyleOnEvent

register

Registers a third party component with the NimbusLookAndFeel. Regions represent Components and areas within Components that act as independent painting areas. Once registered with the NimbusLookAndFeel, NimbusStyles for these Regions can be retrieved via the getStyle method. The NimbusLookAndFeel uses a standard naming scheme for entries in the UIDefaults table. The key for each property, state, painter, and other default registered in UIDefaults for a specific Region will begin with the specified prefix For example, suppose I had a component named JFoo. Suppose I then registered this component with the NimbusLookAndFeel in this manner:

 laf.register(NimbusFooUI.FOO_REGION, "Foo"); 

In this case, I could then register properties for this component with UIDefaults in the following manner:

 UIManager.put("Foo.background", new ColorUIResource(Color.BLACK)); UIManager.put("Foo.Enabled.backgroundPainter", new FooBackgroundPainter()); 

It is also possible to register a named component with Nimbus. For example, suppose you wanted to style the background of a JPanel named «MyPanel» differently from other JPanels. You could accomplish this by doing the following:

 laf.register(Region.PANEL, "\"MyPanel\""); UIManager.put("\"MyPanel\".background", new ColorUIResource(Color.RED)); 

getDerivedColor

public Color getDerivedColor​(String uiDefaultParentName, float hOffset, float sOffset, float bOffset, int aOffset, boolean uiResource)

Get a derived color, derived colors are shared instances and is color value will change when its parent UIDefault color changes.

getDerivedColor

protected final Color getDerivedColor​(Color color1, Color color2, float midPoint, boolean uiResource)

getDerivedColor

protected final Color getDerivedColor​(Color color1, Color color2, float midPoint)

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Читайте также:  Подсветка html тегов vs code

Источник

Nimbus Look and Feel

Nimbus is a polished cross-platform look and feel introduced in the Java SE 6 Update 10 (6u10) release. The following screen capture, from SwingSet3 shows the Nimbus look and feel.

SwingSet3 Screen capture Using Nimbus Look and Feel

Nimbus uses Java 2D vector graphics to draw the user interface (UI), rather than static bitmaps, so the UI can be crisply rendered at any resolution.

Nimbus is highly customizable. You can use the Nimbus look and feel as is, or you can skin (customize) the look with your own brand.

Enabling the Nimbus Look and Feel

For backwards compatibility, Metal is still the default Swing look and feel, but you can change to Nimbus in one of three ways:

    Add the following code to the event-dispatching thread before creating the graphical user interface (GUI):

import javax.swing.UIManager.*; try < for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) < if ("Nimbus".equals(info.getName())) < UIManager.setLookAndFeel(info.getClassName()); break; >> > catch (Exception e) < // If Nimbus is not available, you can set the GUI to another look and feel. >

The first line of code retrieves the list of all installed look and feel implementations for the platform and then iterates through the list to determine if Nimbus is available. If so, Nimbus is set as the look and feel.

Version Note: Do not set the Nimbus look and feel explicitly by invoking the UIManager.setLookAndFeel method because not all versions or implementations of Java SE 6 support Nimbus. Additionally, the location of the Nimbus package changed between the JDK 6 Update 10 and JDK 7 releases. Iterating through all installed look and feel implementations is a more robust approach because if Nimbus is not available, the default look and feel is used. For the JDK 6 Update 10 release, the Nimbus package is located at com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel .

java -Dswing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel MyApp 
swing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel

Источник

Оцените статью