Example #1
0
  /** {@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;
  }