/** 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);
  }
  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();
      }
    }
  }
  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);
    }
  }
  @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);
    }
  }
Exemple #6
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");
  }
Exemple #8
0
 protected LookAndFeel makeLF() {
   System.out.println("Making Metal"); // NON-NLS
   MetalLookAndFeel lf = new MetalLookAndFeel();
   lf.setCurrentTheme(new DefaultMetalTheme());
   return lf;
 }
Exemple #9
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());
        });
  }
Exemple #10
0
 public static void enable() {
   MetalLookAndFeel.setCurrentTheme(new SilverOceanTheme());
 }
 public void actionPerformed(ActionEvent e) {
   MetalLookAndFeel.setCurrentTheme(theme);
   currentTheme = theme;
   swingset.updateLookAndFeel();
 }
Exemple #12
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);
    }
  }