コード例 #1
0
ファイル: NimbusLookAndFeel.java プロジェクト: ronshapiro/j86
 /** Called by UIManager when this look and feel is uninstalled. */
 @Override
 public void uninitialize() {
   super.uninitialize();
   defaults.uninitialize();
   // clear all cached images to free memory
   ImageCache.getInstance().flush();
   UIManager.getDefaults().removePropertyChangeListener(defaultsListener);
 }
コード例 #2
0
ファイル: NimbusLookAndFeel.java プロジェクト: ronshapiro/j86
 /**
  * Get a derived color, derived colors are shared instances and is color value will change when
  * its parent UIDefault color changes.
  *
  * @param uiDefaultParentName The parent UIDefault key
  * @param hOffset The hue offset
  * @param sOffset The saturation offset
  * @param bOffset The brightness offset
  * @param aOffset The alpha offset
  * @param uiResource True if the derived color should be a UIResource, false if it should not be
  * @return The stored derived color
  */
 public Color getDerivedColor(
     String uiDefaultParentName,
     float hOffset,
     float sOffset,
     float bOffset,
     int aOffset,
     boolean uiResource) {
   return defaults.getDerivedColor(
       uiDefaultParentName, hOffset, sOffset, bOffset, aOffset, uiResource);
 }
コード例 #3
0
ファイル: NimbusLookAndFeel.java プロジェクト: ronshapiro/j86
 /** Called by UIManager when this look and feel is installed. */
 @Override
 public void initialize() {
   super.initialize();
   defaults.initialize();
   // create synth style factory
   setStyleFactory(
       new SynthStyleFactory() {
         @Override
         public SynthStyle getStyle(JComponent c, Region r) {
           return defaults.getStyle(c, r);
         }
       });
 }
コード例 #4
0
ファイル: NimbusLookAndFeel.java プロジェクト: ronshapiro/j86
  /**
   * {@inheritDoc}
   *
   * <p>Overridden to return {@code true} when one of the following properties change:
   *
   * <ul>
   *   <li>{@code "Nimbus.Overrides"}
   *   <li>{@code "Nimbus.Overrides.InheritDefaults"}
   *   <li>{@code "JComponent.sizeVariant"}
   * </ul>
   *
   * @since 1.7
   */
  @Override
  protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev) {
    String eName = ev.getPropertyName();

    // These properties affect style cached inside NimbusDefaults (6860433)
    if ("name" == eName
        || "ancestor" == eName
        || "Nimbus.Overrides" == eName
        || "Nimbus.Overrides.InheritDefaults" == eName
        || "JComponent.sizeVariant" == eName) {

      JComponent c = (JComponent) ev.getSource();
      defaults.clearOverridesCache(c);
      return true;
    }

    return super.shouldUpdateStyleOnEvent(ev);
  }
コード例 #5
0
ファイル: NimbusLookAndFeel.java プロジェクト: ronshapiro/j86
 /**
  * Registers a third party component with the NimbusLookAndFeel.
  *
  * <p>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 <code>getStyle</code> method.
  *
  * <p>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 <code>prefix</code>
  *
  * <p>For example, suppose I had a component named JFoo. Suppose I then registered this component
  * with the NimbusLookAndFeel in this manner:
  *
  * <pre><code>
  *     laf.register(NimbusFooUI.FOO_REGION, "Foo");
  * </code></pre>
  *
  * <p>In this case, I could then register properties for this component with UIDefaults in the
  * following manner:
  *
  * <pre><code>
  *     UIManager.put("Foo.background", new ColorUIResource(Color.BLACK));
  *     UIManager.put("Foo.Enabled.backgroundPainter", new FooBackgroundPainter());
  * </code></pre>
  *
  * <p>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:
  *
  * <pre><code>
  *     laf.register(Region.PANEL, "\"MyPanel\"");
  *     UIManager.put("\"MyPanel\".background", new ColorUIResource(Color.RED));
  * </code></pre>
  *
  * @param region The Synth Region that is being registered. Such as Button, or ScrollBarThumb, or
  *     NimbusFooUI.FOO_REGION.
  * @param prefix The UIDefault prefix. For example, could be ComboBox, or if a named components,
  *     "MyComboBox", or even something like ToolBar."MyComboBox"."ComboBox.arrowButton"
  */
 public void register(Region region, String prefix) {
   defaults.register(region, prefix);
 }
コード例 #6
0
ファイル: NimbusLookAndFeel.java プロジェクト: ronshapiro/j86
  /** {@inheritDoc} */
  @Override
  public UIDefaults getDefaults() {
    if (uiDefaults == null) {
      // Detect platform
      String osName = getSystemProperty("os.name");
      boolean isWindows = osName != null && osName.contains("Windows");

      // We need to call super for basic's properties file.
      uiDefaults = super.getDefaults();
      defaults.initializeDefaults(uiDefaults);

      // Install Keybindings
      if (isWindows) {
        WindowsKeybindings.installKeybindings(uiDefaults);
      } else {
        GTKKeybindings.installKeybindings(uiDefaults);
      }

      // Add Titled Border
      uiDefaults.put("TitledBorder.titlePosition", TitledBorder.ABOVE_TOP);
      uiDefaults.put("TitledBorder.border", new BorderUIResource(new LoweredBorder()));
      uiDefaults.put(
          "TitledBorder.titleColor", getDerivedColor("text", 0.0f, 0.0f, 0.23f, 0, true));
      uiDefaults.put(
          "TitledBorder.font", new NimbusDefaults.DerivedFont("defaultFont", 1f, true, null));

      // Choose Dialog button positions
      uiDefaults.put("OptionPane.isYesLast", !isWindows);

      // Store Table ScrollPane Corner Component
      uiDefaults.put(
          "Table.scrollPaneCornerComponent",
          new UIDefaults.ActiveValue() {
            @Override
            public Object createValue(UIDefaults table) {
              return new TableScrollPaneCorner();
            }
          });

      // Setup the settings for ToolBarSeparator which is custom
      // installed for Nimbus
      uiDefaults.put("ToolBarSeparator[Enabled].backgroundPainter", new ToolBarSeparatorPainter());

      // Populate UIDefaults with a standard set of properties
      for (String componentKey : COMPONENT_KEYS) {
        String key = componentKey + ".foreground";
        if (!uiDefaults.containsKey(key)) {
          uiDefaults.put(key, new NimbusProperty(componentKey, "textForeground"));
        }
        key = componentKey + ".background";
        if (!uiDefaults.containsKey(key)) {
          uiDefaults.put(key, new NimbusProperty(componentKey, "background"));
        }
        key = componentKey + ".font";
        if (!uiDefaults.containsKey(key)) {
          uiDefaults.put(key, new NimbusProperty(componentKey, "font"));
        }
        key = componentKey + ".disabledText";
        if (!uiDefaults.containsKey(key)) {
          uiDefaults.put(key, new NimbusProperty(componentKey, "Disabled", "textForeground"));
        }
        key = componentKey + ".disabled";
        if (!uiDefaults.containsKey(key)) {
          uiDefaults.put(key, new NimbusProperty(componentKey, "Disabled", "background"));
        }
      }

      // FileView icon keys are used by some applications, we don't have
      // a computer icon at the moment so using home icon for now
      uiDefaults.put("FileView.computerIcon", new LinkProperty("FileChooser.homeFolderIcon"));
      uiDefaults.put("FileView.directoryIcon", new LinkProperty("FileChooser.directoryIcon"));
      uiDefaults.put("FileView.fileIcon", new LinkProperty("FileChooser.fileIcon"));
      uiDefaults.put("FileView.floppyDriveIcon", new LinkProperty("FileChooser.floppyDriveIcon"));
      uiDefaults.put("FileView.hardDriveIcon", new LinkProperty("FileChooser.hardDriveIcon"));
    }
    return uiDefaults;
  }