@Override
    @SuppressWarnings("unchecked")
    public void paintIcon(final Component c, final Graphics g, final int x, final int y) {
      JCheckBox cb = (JCheckBox) c;
      javax.swing.ButtonModel model = cb.getModel();

      if (ThemeManager.isLookAndFeelNimbus()) {
        icon.paintIcon(c, g, x, y);

        if (c.hasFocus()) {
          nimbusFocusBorder.paintBorder(g, x, y, iconWidth, iconHeight);
        }

        drawIndeterminateNimbusLine(g, x, y);
      } else {
        if (model.isEnabled()) {
          if (model.isPressed() && model.isArmed()) {
            g.setColor(MetalLookAndFeel.getControlShadow());
            g.fillRect(x, y, iconWidth - 1, iconHeight - 1);
            drawPressed3DBorder(g, x, y, iconWidth, iconHeight);
          } else {
            drawFlush3DBorder(g, x, y, iconWidth, iconHeight);
          }
          g.setColor(MetalLookAndFeel.getControlInfo());
        } else {
          g.setColor(MetalLookAndFeel.getControlShadow());
          g.drawRect(x, y, iconWidth - 1, iconHeight - 1);
        }

        drawIndeterminateLine(g, x, y);
      }
    }
  /** Sets current LAF. The method doesn't update component hierarchy. */
  @Override
  public void setCurrentLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo) {
    if (findLaf(lookAndFeelInfo.getClassName()) == null) {
      LOG.error("unknown LookAndFeel : " + lookAndFeelInfo);
      return;
    }
    // Set L&F
    if (IdeaLookAndFeelInfo.CLASS_NAME.equals(
        lookAndFeelInfo.getClassName())) { // that is IDEA default LAF
      IdeaLaf laf = new IdeaLaf();
      MetalLookAndFeel.setCurrentTheme(new IdeaBlueMetalTheme());
      try {
        UIManager.setLookAndFeel(laf);
      } catch (Exception e) {
        Messages.showMessageDialog(
            IdeBundle.message(
                "error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()),
            CommonBundle.getErrorTitle(),
            Messages.getErrorIcon());
        return;
      }
    } else if (DarculaLookAndFeelInfo.CLASS_NAME.equals(lookAndFeelInfo.getClassName())) {
      DarculaLaf laf = new DarculaLaf();
      try {
        UIManager.setLookAndFeel(laf);
        JBColor.setDark(true);
        IconLoader.setUseDarkIcons(true);
      } catch (Exception e) {
        Messages.showMessageDialog(
            IdeBundle.message(
                "error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()),
            CommonBundle.getErrorTitle(),
            Messages.getErrorIcon());
        return;
      }
    } else { // non default LAF
      try {
        LookAndFeel laf =
            ((LookAndFeel) Class.forName(lookAndFeelInfo.getClassName()).newInstance());
        if (laf instanceof MetalLookAndFeel) {
          MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
        }
        UIManager.setLookAndFeel(laf);
      } catch (Exception e) {
        Messages.showMessageDialog(
            IdeBundle.message(
                "error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()),
            CommonBundle.getErrorTitle(),
            Messages.getErrorIcon());
        return;
      }
    }
    myCurrentLaf =
        ObjectUtils.chooseNotNull(findLaf(lookAndFeelInfo.getClassName()), lookAndFeelInfo);

    checkLookAndFeel(lookAndFeelInfo, false);
  }
  static void initLookAndFeel() {
    MetalLookAndFeel mlf = new MetalLookAndFeel();
    mlf.setCurrentTheme(new SipCommunicatorColorTheme());

    try {
      UIManager.setLookAndFeel(mlf);
    } catch (UnsupportedLookAndFeelException ex) {
      console.error("Failed to set custom look and feel", ex);
    }
  }
  private void initLookAndFeelAplicacion(String loolAndFeelStr) {

    if (lookAndFeel != null) {
      if (loolAndFeelStr.equals("Metal")) {
        lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
        //  an alternative way to set the Metal L&F is to replace the
        // previous line with:
        // lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";

      } else if (loolAndFeelStr.equals("System")) {
        lookAndFeel = UIManager.getSystemLookAndFeelClassName();
      } else if (loolAndFeelStr.equals("Motif")) {
        lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
      } else if (loolAndFeelStr.equals("GTK")) {
        lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
      } else if (loolAndFeelStr.equals("Nimbus")) {
        lookAndFeel = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
      } else {
        System.err.println("Valor inesperado para LOOKANDFEEL especificado: " + lookAndFeel);
        lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
      }

      try {

        UIManager.setLookAndFeel(lookAndFeel);

        // If L&F = "Metal", set the theme

        if (lookAndFeel.equals("Metal")) {
          if (THEME.equals("DefaultMetal")) {
            MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
          } else if (THEME.equals("Ocean")) {
            MetalLookAndFeel.setCurrentTheme(new OceanTheme());
          } else {
            MetalLookAndFeel.setCurrentTheme(new TestTheme());
          }

          UIManager.setLookAndFeel(new MetalLookAndFeel());
        }
      } catch (ClassNotFoundException e) {
        System.err.println("Couldn't find class for specified look and feel:" + lookAndFeel);
        System.err.println("Did you include the L&F library in the class path?");
        System.err.println("Using the default look and feel.");
      } catch (UnsupportedLookAndFeelException e) {
        System.err.println(
            "Can't use the specified look and feel (" + lookAndFeel + ") on this platform.");
        System.err.println("Using the default look and feel.");
      } catch (Exception e) {
        System.err.println(
            "Couldn't get specified look and feel (" + lookAndFeel + "), for some reason.");
        System.err.println("Using the default look and feel.");
        e.printStackTrace();
      }
    }
  }
 private static void drawFlush3DBorder(
     final Graphics g, final int x, final int y, final int w, final int h) {
   g.translate(x, y);
   g.setColor(MetalLookAndFeel.getControlDarkShadow());
   g.drawRect(0, 0, w - 2, h - 2);
   g.setColor(MetalLookAndFeel.getControlHighlight());
   g.drawRect(1, 1, w - 2, h - 2);
   g.setColor(MetalLookAndFeel.getControl());
   g.drawLine(0, h - 1, 1, h - 2);
   g.drawLine(w - 1, 0, w - 2, 1);
   g.translate(-x, -y);
 }
 private static void drawPressed3DBorder(
     final Graphics g, final int x, final int y, final int w, final int h) {
   g.translate(x, y);
   drawFlush3DBorder(g, 0, 0, w, h);
   g.setColor(MetalLookAndFeel.getControlShadow());
   g.drawLine(1, 1, 1, h - 2);
   g.drawLine(1, 1, w - 2, 1);
   g.translate(-x, -y);
 }
  @Override
  public UIDefaults getDefaults() {
    try {
      final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
      superMethod.setAccessible(true);
      final UIDefaults metalDefaults = (UIDefaults) superMethod.invoke(new MetalLookAndFeel());

      final UIDefaults defaults = (UIDefaults) superMethod.invoke(base);
      if (SystemInfo.isLinux) {
        if (!Registry.is("darcula.use.native.fonts.on.linux")) {
          Font font = findFont("DejaVu Sans");
          if (font != null) {
            for (Object key : defaults.keySet()) {
              if (key instanceof String && ((String) key).endsWith(".font")) {
                defaults.put(key, new FontUIResource(font.deriveFont(13f)));
              }
            }
          }
        } else if (Arrays.asList("CN", "JP", "KR", "TW")
            .contains(Locale.getDefault().getCountry())) {
          for (Object key : defaults.keySet()) {
            if (key instanceof String && ((String) key).endsWith(".font")) {
              final Font font = defaults.getFont(key);
              if (font != null) {
                defaults.put(key, new FontUIResource("Dialog", font.getStyle(), font.getSize()));
              }
            }
          }
        }
      }

      LafManagerImpl.initInputMapDefaults(defaults);
      initIdeaDefaults(defaults);
      patchStyledEditorKit(defaults);
      patchComboBox(metalDefaults, defaults);
      defaults.remove("Spinner.arrowButtonBorder");
      defaults.put("Spinner.arrowButtonSize", JBUI.size(16, 5).asUIResource());
      MetalLookAndFeel.setCurrentTheme(createMetalTheme());
      if (SystemInfo.isWindows && Registry.is("ide.win.frame.decoration")) {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
      }
      if (SystemInfo.isLinux && JBUI.isHiDPI()) {
        applySystemFonts(defaults);
      }
      defaults.put("EditorPane.font", defaults.getFont("TextField.font"));
      return defaults;
    } catch (Exception e) {
      log(e);
    }
    return super.getDefaults();
  }
  public static void setTheme(AbstractTheme theme) {
    if (theme == null) {
      return;
    }

    MetalLookAndFeel.setCurrentTheme(theme);
    myTheme = theme;
    if (isWindowDecorationOn()) {
      DecorationHelper.decorateWindows(Boolean.TRUE);
    } else {
      DecorationHelper.decorateWindows(Boolean.FALSE);
    }
  }
Beispiel #9
0
  private static void setTheme(final String theme) {

    try {
      Class<?> themeClass = Class.forName(theme);
      MetalTheme themeObject = (MetalTheme) themeClass.newInstance();
      MetalLookAndFeel.setCurrentTheme(themeObject);
    } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
      Logger.getLogger(ThemeManager.class.getName())
          .log(
              Level.SEVERE,
              "Could not install theme: {0}\n{1}",
              new Object[] {theme, e.toString()});
    }
  }
  public static void main(String[] args) {
    long start = System.currentTimeMillis();
    LauncherDirectories directories = new LauncherDirectories();
    Directories.instance = directories;

    // Prefer IPv4
    System.setProperty("java.net.preferIPv4Stack", "true");

    params = setupParameters(args);

    cleanup();

    SplashScreen splash =
        new SplashScreen(
            Toolkit.getDefaultToolkit()
                .getImage(
                    SplashScreen.class.getResource(
                        "/org/spoutcraft/launcher/resources/splash.png")));
    splash.setVisible(true);
    directories.setSplashScreen(splash);

    MetalLookAndFeel.setCurrentTheme(new OceanTheme());
    setLookAndFeel();

    console = new Console(params.isConsole());
    SpoutcraftLauncher.logger = setupLogger();
    console.setRotatingFileHandler(SpoutcraftLauncher.handler);

    int launcherBuild = parseInt(getLauncherBuild(), -1);
    logger.info("------------------------------------------");
    logger.info("Love Launcher is starting....");
    logger.info("Launcher Build: " + launcherBuild);

    params.logParameters(logger);

    Runtime.getRuntime().addShutdownHook(new ShutdownThread(console));

    // Set up the launcher and load login frame
    Launcher launcher = new Launcher();

    splash.dispose();
    launcher.startup();

    logger.info("Launcher took: " + (System.currentTimeMillis() - start) + "ms to start");
  }
Beispiel #11
0
  private void paintOceanIcon(Component c, Graphics g, int x, int y) {
    ButtonModel model = ((JCheckBoxMenuItem) c).getModel();

    g.translate(x, y);
    int w = getIconWidth();
    int h = getIconHeight();
    if (model.isEnabled()) {
      if (model.isPressed() && model.isArmed()) {
        g.setColor(MetalLookAndFeel.getControlShadow());
        g.fillRect(0, 0, w, h);
        g.setColor(MetalLookAndFeel.getControlDarkShadow());
        g.fillRect(0, 0, w, 2);
        g.fillRect(0, 2, 2, h - 2);
        g.fillRect(w - 1, 1, 1, h - 1);
        g.fillRect(1, h - 1, w - 2, 1);
      } else if (model.isRollover()) {
        MetalUtilsCustom.drawGradient(c, g, "CheckBox.gradient", 0, 0, w, h, true);
        g.setColor(MetalLookAndFeel.getControlDarkShadow());
        g.drawRect(0, 0, w - 1, h - 1);
        g.setColor(MetalLookAndFeel.getPrimaryControl());
        g.drawRect(1, 1, w - 3, h - 3);
        g.drawRect(2, 2, w - 5, h - 5);
      } else {
        MetalUtilsCustom.drawGradient(c, g, "CheckBox.gradient", 0, 0, w, h, true);
        g.setColor(MetalLookAndFeel.getControlDarkShadow());
        g.drawRect(0, 0, w - 1, h - 1);
      }
      g.setColor(MetalLookAndFeel.getControlInfo());
    } else {
      g.setColor(MetalLookAndFeel.getControlDarkShadow());
      g.drawRect(0, 0, w - 1, h - 1);
    }
    g.translate(-x, -y);
    if (model.isSelected()) {
      drawCheck(g, x, y);
    }
  }
  protected void initComponentDefaults(UIDefaults table) {
    super.initComponentDefaults(table);

    BaseBorders.initDefaults();
    BaseIcons.initDefaults();

    Object textFieldBorder = getBorderFactory().getTextFieldBorder();
    Object comboBoxBorder = getBorderFactory().getComboBoxBorder();
    Object scrollPaneBorder = getBorderFactory().getScrollPaneBorder();
    Object tableScrollPaneBorder = getBorderFactory().getTableScrollPaneBorder();
    Object tabbedPaneBorder = getBorderFactory().getTabbedPaneBorder();
    Object buttonBorder = getBorderFactory().getButtonBorder();
    Object toggleButtonBorder = getBorderFactory().getToggleButtonBorder();
    Object titledBorderBorder =
        new UIDefaults.ProxyLazyValue(
            "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
            new Object[] {getFrameColor()});
    Object menuBarBorder = getBorderFactory().getMenuBarBorder();
    Object popupMenuBorder = getBorderFactory().getPopupMenuBorder();
    Object menuItemBorder = getBorderFactory().getMenuItemBorder();
    Object toolBarBorder = getBorderFactory().getToolBarBorder();
    Object progressBarBorder = getBorderFactory().getProgressBarBorder();
    Object toolTipBorder =
        new UIDefaults.ProxyLazyValue(
            "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
            new Object[] {getFrameColor()});
    Object focusCellHighlightBorder =
        new UIDefaults.ProxyLazyValue(
            "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
            new Object[] {getFocusCellColor()});
    Object optionPaneBorder = BorderFactory.createEmptyBorder(0, 0, 0, 0);
    Object optionPaneMessageAreaBorder = BorderFactory.createEmptyBorder(8, 8, 8, 8);
    Object optionPaneButtonAreaBorder = BorderFactory.createEmptyBorder(0, 8, 8, 8);
    Object windowBorder = getBorderFactory().getInternalFrameBorder();

    Color c = getBackgroundColor();
    ColorUIResource progressBarBackground = new ColorUIResource(ColorHelper.brighter(c, 20));

    // DEFAULTS TABLE
    Object[] defaults = {
      "controlTextFont", getControlTextFont(),
      "systemTextFont ", getSystemTextFont(),
      "userTextFont", getUserTextFont(),
      "menuTextFont", getMenuTextFont(),
      "windowTitleFont", getWindowTitleFont(),
      "subTextFont", getSubTextFont(),
      "Label.font", getUserTextFont(),
      "Label.background", getBackgroundColor(),
      "Label.foreground", getForegroundColor(),
      "Label.disabledText", getDisabledForegroundColor(),
      "Label.disabledShadow", getWhite(),
      // Text (Note: many are inherited)
      "TextField.border", textFieldBorder,
      "TextField.foreground", getInputForegroundColor(),
      "TextField.background", getInputBackgroundColor(),
      "TextField.disabledForeground", getDisabledForegroundColor(),
      "TextField.disabledBackground", getDisabledBackgroundColor(),
      "TextField.inactiveForeground", getDisabledForegroundColor(),
      "TextField.inactiveBackground", getDisabledBackgroundColor(),
      "TextArea.foreground", getInputForegroundColor(),
      "TextArea.background", getInputBackgroundColor(),
      "TextArea.disabledForeground", getDisabledForegroundColor(),
      "TextArea.disabledBackground", getDisabledBackgroundColor(),
      "TextArea.inactiveForeground", getDisabledForegroundColor(),
      "TextArea.inactiveBackground", getDisabledBackgroundColor(),
      "EditorPane.foreground", getInputForegroundColor(),
      "EditorPane.background", getInputBackgroundColor(),
      "EditorPane.disabledForeground", getDisabledForegroundColor(),
      "EditorPane.disabledBackground", getDisabledBackgroundColor(),
      "EditorPane.inactiveForeground", getDisabledForegroundColor(),
      "EditorPane.inactiveBackground", getDisabledBackgroundColor(),
      "FormattedTextField.border", textFieldBorder,
      "FormattedTextField.foreground", getInputForegroundColor(),
      "FormattedTextField.background", getInputBackgroundColor(),
      "FormattedTextField.disabledForeground", getDisabledForegroundColor(),
      "FormattedTextField.disabledBackground", getDisabledBackgroundColor(),
      "FormattedTextField.inactiveForeground", getDisabledForegroundColor(),
      "FormattedTextField.inactiveBackground", getDisabledBackgroundColor(),
      "PasswordField.border", textFieldBorder,
      "PasswordField.foreground", getInputForegroundColor(),
      "PasswordField.background", getInputBackgroundColor(),
      "PasswordField.disabledForeground", getDisabledForegroundColor(),
      "PasswordField.disabledBackground", getDisabledBackgroundColor(),
      "PasswordField.inactiveForeground", getDisabledForegroundColor(),
      "PasswordField.inactiveBackground", getDisabledBackgroundColor(),
      // Buttons
      "Button.background", getButtonBackgroundColor(),
      "Button.foreground", getButtonForegroundColor(),
      "Button.disabledText", getDisabledForegroundColor(),
      "Button.disabledShadow", getWhite(),
      "Button.select", getSelectionBackgroundColor(),
      "Button.border", buttonBorder,
      "Button.frame", getFrameColor(),
      "Button.focus", getFocusColor(),
      "Button.rolloverColor", getTheme().getRolloverColor(),
      "CheckBox.font", getUserTextFont(),
      "CheckBox.background", getBackgroundColor(),
      "CheckBox.foreground", getForegroundColor(),
      "CheckBox.disabledText", getDisabledForegroundColor(),
      "CheckBox.disabledShadow", getWhite(),
      "Checkbox.select", getSelectionBackgroundColor(),
      "CheckBox.focus", getFocusColor(),
      "CheckBox.icon", getIconFactory().getCheckBoxIcon(),
      "RadioButton.font", getUserTextFont(),
      "RadioButton.background", getBackgroundColor(),
      "RadioButton.foreground", getForegroundColor(),
      "RadioButton.disabledText", getDisabledForegroundColor(),
      "RadioButton.disabledShadow", getWhite(),
      "RadioButton.select", getSelectionBackgroundColor(),
      "RadioButton.icon", getIconFactory().getRadioButtonIcon(),
      "RadioButton.focus", getFocusColor(),
      "ToggleButton.background", getButtonBackgroundColor(),
      "ToggleButton.foreground", getButtonForegroundColor(),
      "ToggleButton.select", getSelectionBackgroundColor(),
      "ToggleButton.text", getButtonForegroundColor(),
      "ToggleButton.disabledText", getDisabledForegroundColor(),
      "ToggleButton.disabledShadow", getWhite(),
      "ToggleButton.disabledSelectedText", getDisabledForegroundColor(),
      "ToggleButton.disabledBackground", getButtonBackgroundColor(),
      "ToggleButton.disabledSelectedBackground", getSelectionBackgroundColor(),
      "ToggleButton.focus", getFocusColor(),
      "ToggleButton.border", toggleButtonBorder,
      // ToolTip
      "ToolTip.border", toolTipBorder,
      "ToolTip.foreground", getTooltipForegroundColor(),
      "ToolTip.background", getTooltipBackgroundColor(),
      // Slider
      "Slider.border", null,
      "Slider.foreground", getFrameColor(),
      "Slider.background", getBackgroundColor(),
      "Slider.focus", getFocusColor(),
      "Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0),
      "Slider.trackWidth", new Integer(7),
      "Slider.majorTickLength", new Integer(6),
      // Progress Bar
      "ProgressBar.border", progressBarBorder,
      "ProgressBar.background", progressBarBackground,
      "ProgressBar.selectionForeground", getSelectionForegroundColor(),
      "ProgressBar.selectionBackground", getForegroundColor(),
      // Combo Box
      "ComboBox.border", comboBoxBorder,
      "ComboBox.background", getInputBackgroundColor(),
      "ComboBox.foreground", getInputForegroundColor(),
      "ComboBox.selectionBackground", getSelectionBackgroundColor(),
      "ComboBox.selectionForeground", getSelectionForegroundColor(),
      "ComboBox.selectionBorderColor", getFocusColor(),
      "ComboBox.disabledBackground", getDisabledBackgroundColor(),
      "ComboBox.disabledForeground", getDisabledForegroundColor(),
      "ComboBox.listBackground", getInputBackgroundColor(),
      "ComboBox.listForeground", getInputForegroundColor(),
      "ComboBox.font", getUserTextFont(),
      // Panel
      "Panel.foreground", getForegroundColor(),
      "Panel.background", getBackgroundColor(),
      "Panel.darkBackground", getTheme().getBackgroundColorDark(),
      "Panel.lightBackground", getTheme().getBackgroundColorLight(),
      "Panel.alterBackground", getTheme().getAlterBackgroundColor(),
      "Panel.font", getUserTextFont(),
      // RootPane
      "RootPane.frameBorder", windowBorder,
      "RootPane.plainDialogBorder", windowBorder,
      "RootPane.informationDialogBorder", windowBorder,
      "RootPane.errorDialogBorder", windowBorder,
      "RootPane.colorChooserDialogBorder", windowBorder,
      "RootPane.fileChooserDialogBorder", windowBorder,
      "RootPane.questionDialogBorder", windowBorder,
      "RootPane.warningDialogBorder", windowBorder,
      // InternalFrame
      "InternalFrame.border", getBorderFactory().getInternalFrameBorder(),
      "InternalFrame.font", getWindowTitleFont(),
      "InternalFrame.paletteBorder", getBorderFactory().getPaletteBorder(),
      "InternalFrame.paletteTitleHeight", new Integer(11),
      "InternalFrame.paletteCloseIcon", getIconFactory().getPaletteCloseIcon(),
      "InternalFrame.icon", getIconFactory().getMenuIcon(),
      "InternalFrame.iconifyIcon", getIconFactory().getIconIcon(),
      "InternalFrame.maximizeIcon", getIconFactory().getMaxIcon(),
      "InternalFrame.minimizeIcon", getIconFactory().getMinIcon(),
      "InternalFrame.closeIcon", getIconFactory().getCloseIcon(),

      // Titled Border
      "TitledBorder.titleColor", getForegroundColor(),
      "TitledBorder.border", titledBorderBorder,
      // List
      "List.focusCellHighlightBorder", focusCellHighlightBorder,
      "List.font", getUserTextFont(),
      "List.foreground", getInputForegroundColor(),
      "List.background", getInputBackgroundColor(),
      "List.selectionForeground", getSelectionForegroundColor(),
      "List.selectionBackground", getSelectionBackgroundColor(),
      "List.disabledForeground", getDisabledForegroundColor(),
      "List.disabledBackground", getDisabledBackgroundColor(),
      // ScrollBar
      "ScrollBar.background", getControlBackgroundColor(),
      "ScrollBar.highlight", getControlHighlightColor(),
      "ScrollBar.shadow", getControlShadowColor(),
      "ScrollBar.darkShadow", getControlDarkShadowColor(),
      "ScrollBar.thumb", getControlBackgroundColor(),
      "ScrollBar.thumbShadow", getControlShadowColor(),
      "ScrollBar.thumbHighlight", getControlHighlightColor(),
      "ScrollBar.width", new Integer(17),
      "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
      // ScrollPane
      "ScrollPane.border", scrollPaneBorder,
      "ScrollPane.foreground", getForegroundColor(),
      "ScrollPane.background", getBackgroundColor(),
      // Viewport
      "Viewport.foreground", getForegroundColor(),
      "Viewport.background", getBackgroundColor(),
      "Viewport.font", getUserTextFont(),

      // Tabbed Pane
      "TabbedPane.boder", tabbedPaneBorder,
      "TabbedPane.background", getBackgroundColor(),
      "TabbedPane.tabAreaBackground", getTabAreaBackgroundColor(),
      "TabbedPane.unselectedBackground", getControlColorDark(),
      "TabbedPane.foreground", getControlForegroundColor(),
      "TabbedPane.selected", getBackgroundColor(),
      "TabbedPane.selectedForeground", getTabSelectionForegroundColor(),
      "TabbedPane.tabAreaInsets", new InsetsUIResource(5, 5, 5, 5),
      "TabbedPane.contentBorderInsets", new InsetsUIResource(0, 0, 0, 0),
      "TabbedPane.tabInsets", new InsetsUIResource(1, 6, 1, 6),
      "TabbedPane.focus", getFocusColor(),
      // TabbedPane ScrollButton
      "TabbedPane.selected", getButtonBackgroundColor(),
      "TabbedPane.shadow", new ColorUIResource(180, 180, 180),
      "TabbedPane.darkShadow", new ColorUIResource(120, 120, 120),
      "TabbedPane.highlight", new ColorUIResource(Color.white),
      // Tab Colors in Netbeans
      "tab_unsel_fill", getControlBackgroundColor(),
      "tab_sel_fill", getControlBackgroundColor(),
      // Table
      "Table.focusCellHighlightBorder", focusCellHighlightBorder,
      "Table.scrollPaneBorder", tableScrollPaneBorder,
      "Table.foreground", getInputForegroundColor(),
      "Table.background", getInputBackgroundColor(),
      "Table.gridColor", getGridColor(),
      "TableHeader.foreground", getControlForegroundColor(),
      "TableHeader.background", getBackgroundColor(),
      "TableHeader.cellBorder", getBorderFactory().getTableHeaderBorder(),
      // MenuBar
      "MenuBar.border", menuBarBorder,
      "MenuBar.foreground", getMenuForegroundColor(),
      "MenuBar.background", getMenuBackgroundColor(),
      // Menu
      "Menu.border", menuItemBorder,
      "Menu.borderPainted", Boolean.TRUE,
      "Menu.foreground", getMenuForegroundColor(),
      "Menu.background", getMenuBackgroundColor(),
      "Menu.selectionForeground", getMenuSelectionForegroundColor(),
      "Menu.selectionBackground", getMenuSelectionBackgroundColor(),
      "Menu.disabledForeground", getDisabledForegroundColor(),
      "Menu.acceleratorForeground", getMenuForegroundColor(),
      "Menu.acceleratorSelectionForeground", getMenuSelectionForegroundColor(),
      "Menu.arrowIcon", getIconFactory().getMenuArrowIcon(),
      // Popup Menu
      "PopupMenu.background", getMenuBackgroundColor(),
      "PopupMenu.border", popupMenuBorder,
      // Menu Item
      "MenuItem.border", menuItemBorder,
      "MenuItem.borderPainted", Boolean.TRUE,
      "MenuItem.foreground", getMenuForegroundColor(),
      "MenuItem.background", getMenuBackgroundColor(),
      "MenuItem.selectionForeground", getMenuSelectionForegroundColor(),
      "MenuItem.selectionBackground", getMenuSelectionBackgroundColor(),
      "MenuItem.disabledForeground", getDisabledForegroundColor(),
      "MenuItem.disabledShadow", getWhite(),
      "MenuItem.acceleratorForeground", getMenuForegroundColor(),
      "MenuItem.acceleratorSelectionForeground", getMenuSelectionForegroundColor(),
      "CheckBoxMenuItem.border", menuItemBorder,
      "CheckBoxMenuItem.borderPainted", Boolean.TRUE,
      "CheckBoxMenuItem.foreground", getMenuForegroundColor(),
      "CheckBoxMenuItem.background", getMenuBackgroundColor(),
      "CheckBoxMenuItem.selectionForeground", getMenuSelectionForegroundColor(),
      "CheckBoxMenuItem.selectionBackground", getMenuSelectionBackgroundColor(),
      "CheckBoxMenuItem.disabledForeground", getDisabledForegroundColor(),
      "CheckBoxMenuItem.disabledShadow", getWhite(),
      "CheckBoxMenuItem.acceleratorForeground", getMenuForegroundColor(),
      "CheckBoxMenuItem.acceleratorSelectionForeground", getMenuSelectionForegroundColor(),
      "CheckBoxMenuItem.checkIcon", getIconFactory().getMenuCheckBoxIcon(),
      "RadioButtonMenuItem.border", menuItemBorder,
      "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
      "RadioButtonMenuItem.foreground", getMenuForegroundColor(),
      "RadioButtonMenuItem.background", getMenuBackgroundColor(),
      "RadioButtonMenuItem.selectionForeground", getMenuSelectionForegroundColor(),
      "RadioButtonMenuItem.selectionBackground", getMenuSelectionBackgroundColor(),
      "RadioButtonMenuItem.disabledForeground", getDisabledForegroundColor(),
      "RadioButtonMenuItem.disabledShadow", getWhite(),
      "RadioButtonMenuItem.acceleratorForeground", getMenuForegroundColor(),
      "RadioButtonMenuItem.acceleratorSelectionForeground", getMenuSelectionForegroundColor(),
      "RadioButtonMenuItem.checkIcon", getIconFactory().getMenuRadioButtonIcon(),
      // OptionPane.
      "OptionPane.errorIcon", getIconFactory().getOptionPaneErrorIcon(),
      "OptionPane.informationIcon", getIconFactory().getOptionPaneInformationIcon(),
      "OptionPane.warningIcon", getIconFactory().getOptionPaneWarningIcon(),
      "OptionPane.questionIcon", getIconFactory().getOptionPaneQuestionIcon(),
      "OptionPane.border", optionPaneBorder,
      "OptionPane.messageAreaBorder", optionPaneMessageAreaBorder,
      "OptionPane.buttonAreaBorder", optionPaneButtonAreaBorder,
      // File View
      "FileView.directoryIcon", getIconFactory().getTreeFolderIcon(),
      "FileView.fileIcon", getIconFactory().getTreeLeafIcon(),
      "FileView.computerIcon", getIconFactory().getTreeComputerIcon(),
      "FileView.hardDriveIcon", getIconFactory().getTreeHardDriveIcon(),
      "FileView.floppyDriveIcon", getIconFactory().getTreeFloppyDriveIcon(),
      // File Chooser
      "FileChooser.detailsViewIcon", getIconFactory().getFileChooserDetailViewIcon(),
      "FileChooser.homeFolderIcon", getIconFactory().getFileChooserHomeFolderIcon(),
      "FileChooser.listViewIcon", getIconFactory().getFileChooserListViewIcon(),
      "FileChooser.newFolderIcon", getIconFactory().getFileChooserNewFolderIcon(),
      "FileChooser.upFolderIcon", getIconFactory().getFileChooserUpFolderIcon(),
      // Separator
      "Separator.background", getBackgroundColor(),
      "Separator.foreground", getControlForegroundColor(),
      // SplitPane
      "SplitPane.centerOneTouchButtons", Boolean.TRUE,
      "SplitPane.dividerSize", new Integer(7),
      "SplitPane.border", BorderFactory.createEmptyBorder(),
      // Tree
      "Tree.background", getInputBackgroundColor(),
      "Tree.foreground", getInputForegroundColor(),
      "Tree.textForeground", getInputForegroundColor(),
      "Tree.textBackground", getInputBackgroundColor(),
      "Tree.openIcon", getIconFactory().getTreeFolderIcon(),
      "Tree.closedIcon", getIconFactory().getTreeFolderIcon(),
      "Tree.leafIcon", getIconFactory().getTreeLeafIcon(),
      "Tree.expandedIcon", getIconFactory().getTreeExpandedIcon(),
      "Tree.collapsedIcon", getIconFactory().getTreeCollapsedIcon(),
      "Tree.selectionBorderColor", getFocusCellColor(),
      "Tree.line", getFrameColor(), // horiz lines
      "Tree.hash", getFrameColor(), // legs

      // ToolBar
      "JToolBar.isRollover", Boolean.TRUE,
      "ToolBar.border", toolBarBorder,
      "ToolBar.background", getToolbarBackgroundColor(),
      "ToolBar.foreground", getToolbarForegroundColor(),
      "ToolBar.dockingBackground", getToolbarBackgroundColor(),
      "ToolBar.dockingForeground", getToolbarDockingColor(),
      "ToolBar.floatingBackground", getToolbarBackgroundColor(),
      "ToolBar.floatingForeground", getToolbarForegroundColor(),
    };
    table.putDefaults(defaults);

    if (JTattooUtilities.getJavaVersion() >= 1.5) {
      table.put("Spinner.font", getControlTextFont());
      table.put("Spinner.background", getButtonBackgroundColor());
      table.put("Spinner.foreground", getButtonForegroundColor());
      table.put("Spinner.border", getBorderFactory().getSpinnerBorder());
      table.put("Spinner.arrowButtonInsets", null);
      table.put("Spinner.arrowButtonBorder", BorderFactory.createEmptyBorder());
      table.put("Spinner.editorBorderPainted", Boolean.FALSE);
    }
  }
Beispiel #13
0
  @Override
  public void restored() {
    //        System.setProperty("awt.useSystemAAFontSettings","lcd");
    // Initiate TimingFramework
    //        TimingSource source = new SwingTimerTimingSource(30, TimeUnit.MILLISECONDS);
    //        Animator.setDefaultTimingSource(source); // shared timing source
    //        source.init(); // starts the timer
    // RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
    EventQueue.invokeLater(
        () -> {
          boolean isMac = System.getProperty("os.name").toLowerCase().startsWith("mac");

          Object[] macEntries = null;
          if (isMac) {
            try {
              System.setProperty("apple.laf.useScreenMenuBar", "true");

              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

              macEntries = new Object[7];

              macEntries[0] = UIManager.get("MenuBarUI");
              // macEntries[1] = UIManager.get("MenuUI");
              // macEntries[2] = UIManager.get("MenuItemUI");
              macEntries[3] = UIManager.get("CheckboxMenuItemUI");
              macEntries[4] = UIManager.get("RadioButtonMenuItemUI");
              macEntries[5] = UIManager.get("PopupMenuUI");
              macEntries[6] = UIManager.get("PopupMenuSeparatorUI");

            } catch (ClassNotFoundException ex) {
              Exceptions.printStackTrace(ex);
            } catch (InstantiationException ex) {
              Exceptions.printStackTrace(ex);
            } catch (IllegalAccessException ex) {
              Exceptions.printStackTrace(ex);
            } catch (UnsupportedLookAndFeelException ex) {
              Exceptions.printStackTrace(ex);
            }
          }

          try {
            Integer in = (Integer) UIManager.get("customFontSize"); // NOI18N
            UIManager.getDefaults().clear();

            if (in == null || in <= 11) {
              UIManager.put(
                  "customFontSize", 12
                  //                                (int) Math.ceil(Font.getDefault().getSize())
                  );
            } else {
              UIManager.put("customFontSize", in.intValue());
            }
            ClassLoader cl = Lookup.getDefault().lookup(ClassLoader.class);
            UIManager.put("ClassLoader", cl);
            UIManager.put("Nb.BlueLFCustoms", customs);
            UIManager.put("swing.boldMetal", false);
            MetalLookAndFeel.setCurrentTheme(new BlueTheme());
            LookAndFeel plaf = new blue.plaf.BlueLookAndFeel();
            UIManager.setLookAndFeel(plaf);
          } catch (Exception e) {
            e.printStackTrace();
          }

          UIManager.put(
              DefaultTabbedContainerUI.KEY_EDITOR_CONTENT_BORDER,
              BorderFactory.createEmptyBorder());
          UIManager.put(
              DefaultTabbedContainerUI.KEY_EDITOR_OUTER_BORDER,
              new BlueViewBorder(
                  UIManager.getColor("SplitPane.highlight"),
                  UIManager.getColor("SplitPane.darkShadow")));

          UIManager.put(
              DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder());
          UIManager.put(
              DefaultTabbedContainerUI.KEY_VIEW_OUTER_BORDER,
              new BlueViewBorder(
                  UIManager.getColor("SplitPane.highlight"),
                  UIManager.getColor("SplitPane.darkShadow")));

          UIManager.put("nb.output.foreground", Color.WHITE); // NOI18N

          if (isMac && macEntries != null) {
            UIManager.put("MenuBarUI", macEntries[0]);
            // UIManager.put("MenuUI", macEntries[1]);
            // UIManager.put("MenuItemUI", macEntries[2]);
            UIManager.put("CheckboxMenuItemUI", macEntries[3]);
            UIManager.put("RadioButtonMenuItemUI", macEntries[4]);
            UIManager.put("PopupMenuUI", macEntries[5]);
            UIManager.put("PopupMenuSeparatorUI", macEntries[6]);
          }

          if (isMac) {
            replaceCtrlShortcutsWithMacShortcuts();
          }

          logger.info("Finished blue PLAF installation");

          MacFullScreenUtil.setWindowCanFullScreen(WindowManager.getDefault().getMainWindow());
        });
  }
Beispiel #14
0
 public static void enable() {
   MetalLookAndFeel.setCurrentTheme(new SilverOceanTheme());
 }
 public void actionPerformed(ActionEvent e) {
   MetalLookAndFeel.setCurrentTheme(theme);
   currentTheme = theme;
   swingset.updateLookAndFeel();
 }
Beispiel #16
0
 /** Returns true if we're using the Ocean Theme under the MetalLookAndFeel. */
 public static boolean usingOcean() {
   if (isMetalLookAndFeel()) {
     return (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme);
   }
   return false;
 }
Beispiel #17
0
 protected LookAndFeel makeLF() {
   System.out.println("Making Metal"); // NON-NLS
   MetalLookAndFeel lf = new MetalLookAndFeel();
   lf.setCurrentTheme(new DefaultMetalTheme());
   return lf;
 }
Beispiel #18
0
  /** Run method of KilCli thread, creates a KilCli object and executes it */
  @Override
  public void run() {
    if (tmp != -11) {
      play();
    } else {
      // ClearLookManager.setMode(ClearLookMode.valueOf("On"));
      // ClearLookManager.setPolicy("com.jgoodies.clearlook.DefaultClearLookPolicy");
      String slash = System.getProperty("file.separator");
      File srcFile = new File("config" + slash + "display.txt");
      if (!srcFile.exists()) {
        // display some kind of message that the file doesn't exist
      } else if (!srcFile.isFile() || !srcFile.canRead()) {
        // display error that it can't read from the file
      } else {
        try {
          BufferedReader inFile = new BufferedReader(new FileReader(srcFile));
          try {
            tokenizer = new StringTokenizer(inFile.readLine(), "|");
            inFile.close();
          } catch (IOException ioe) {
            System.err.println(ioe);
            ioe.printStackTrace();
          }

          if (tokenizer.hasMoreTokens()) {
            laf = tokenizer.nextToken();
          }
          if (tokenizer.hasMoreTokens()) {
            themeString = tokenizer.nextToken();
          }
          if (tokenizer.hasMoreTokens()) {
            game = Integer.parseInt(tokenizer.nextToken());
          }
          tokenizer = null;
          try {
            if (laf.equals("com.l2fprod.gui.plaf.skin.SkinLookAndFeel")) {
              SkinLookAndFeel.setSkin(SkinLookAndFeel.loadThemePack(themeString));
            } else if (laf.startsWith("com.jgoodies")) {
              File file = new File(themeString);
              InputStream in = new FileInputStream(file);
              theme = new CustomTheme(in);
              PlasticLookAndFeel.setMyCurrentTheme(theme);
            } else if (laf.equalsIgnoreCase(mac)) {
              UIManager.setLookAndFeel(laf);
              SwingUtilities.updateComponentTreeUI(menu);
            } else if (laf.equalsIgnoreCase(gtk)) {
              UIManager.setLookAndFeel(laf);
              SwingUtilities.updateComponentTreeUI(menu);
            } else if (laf.equalsIgnoreCase(windows)) {
              UIManager.setLookAndFeel(laf);
              SwingUtilities.updateComponentTreeUI(menu);
            } else {
              if (themeString.toLowerCase().equals("default")) {
                theme = new PlasticTheme();
              } else if (themeString.toLowerCase().equals("contrast")) {
                theme = new ContrastTheme();
              } else {
                File file = new File(themeString);
                InputStream in = new FileInputStream(file);
                theme = new CustomTheme(in);
                in.close();
              }

              MetalLookAndFeel.setCurrentTheme(theme);
            }
            UIManager.setLookAndFeel(laf);
            // SwingUtilities.updatecomponentTreeUI(this);
          } catch (Exception e) {
            System.out.println("error changing l&f");
            e.printStackTrace();
            // SMTPClient.sendError("displayTXT", e);
          }
        } catch (FileNotFoundException fnfe) {
        }
      }

      menu = new JFrame("KilCli Menu");
      menu.setResizable(false);
      Image icon = Toolkit.getDefaultToolkit().getImage("kilcli.jpg");
      menu.setIconImage(icon);
      JPanel box = new JPanel();
      JLabel label = new JLabel("<html>&nbsp;&nbsp;What do you wish to do?<br></html>");
      box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
      box.add(label);

      final int numButtons = 4;
      JRadioButton[] radioButtons = new JRadioButton[numButtons];
      final ButtonGroup group = new ButtonGroup();

      JButton playButton = null;

      final String terrisCommand = "terris";
      final String cosrinCommand = "cosrin";

      final String logCommand = "log";
      final String quitCommand = "quit";

      radioButtons[0] = new JRadioButton("Play Legends of Terris");
      radioButtons[0].setActionCommand(terrisCommand);

      radioButtons[1] = new JRadioButton("Play Cosrin: New Dawn");
      radioButtons[1].setActionCommand(cosrinCommand);

      radioButtons[2] = new JRadioButton("View an existing log file");
      radioButtons[2].setActionCommand(logCommand);

      radioButtons[3] = new JRadioButton("Quit");
      radioButtons[3].setActionCommand(quitCommand);

      for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
      }
      radioButtons[game].setSelected(true);

      playButton = new JButton("Do It!");
      playButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              if (tmp == -11) {
                String command = group.getSelection().getActionCommand();
                if (command == terrisCommand) {
                  tmp = 0;
                } else if (command == cosrinCommand) {
                  tmp = 1;
                } else if (command == logCommand) {
                  tmp = 3;
                } else {
                  tmp = 4;
                }
              }
              reconnect(null);
            }
          });

      for (int i = 0; i < numButtons; i++) {
        box.add(radioButtons[i]);
      }

      JPanel pane = new JPanel();
      pane.setLayout(new BorderLayout());
      pane.add(box, BorderLayout.NORTH);
      pane.add(playButton, BorderLayout.SOUTH);
      menu.getRootPane().setDefaultButton(playButton);
      menu.getContentPane().add(pane);
      menu.pack();
      menu.setSize(menu.getWidth() + 15, menu.getHeight() + 15);
      menu.addWindowListener(
          new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
              System.exit(0);
            }
          });

      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      Dimension labelSize = menu.getPreferredSize();
      menu.setLocation(
          screenSize.width / 2 - (labelSize.width / 2),
          screenSize.height / 2 - (labelSize.height / 2));
      menu.setVisible(true);
    }
  }