コード例 #1
2
  public void changeLAF(int iLAFIndex) {
    try {
      // Change LAF
      if (iLAFIndex >= marrLaf.length) iLAFIndex = marrLaf.length - 1;
      UIManager.setLookAndFeel(
          (LookAndFeel) Class.forName(marrLaf[iLAFIndex].getClassName()).newInstance());

      // Update UI
      ((JMenuItem) mvtLAFItem.elementAt(iLAFIndex)).setSelected(true);
      SwingUtilities.updateComponentTreeUI(this);
      SwingUtilities.updateComponentTreeUI(mnuMain);
      WindowManager.updateLookAndField();

      // Store config
      try {
        Hashtable prt = Global.loadHashtable(Global.FILE_CONFIG);
        prt.put("LAF", String.valueOf(iLAFIndex));
        Global.storeHashtable(prt, Global.FILE_CONFIG);
      } catch (Exception e) {
      }
    } catch (Exception e) {
      e.printStackTrace();
      MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
    }
  }
コード例 #2
0
ファイル: RosterTree.java プロジェクト: Easygor/experiment
 public MacRenderer() {
   renderer = new JLabel();
   renderer.setOpaque(Preferences.getBoolean("jeti", "bmw", true));
   renderer.setBackground(UIManager.getColor("Tree.selectionBackground"));
   renderer.setForeground(UIManager.getColor("Tree.textForeground"));
   renderer.setFont(UIManager.getFont("Tree.font"));
 }
コード例 #3
0
 public static void main(String[] args) {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
   }
   new TabbedDialog();
 }
コード例 #4
0
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   final Module module = value instanceof Module ? (Module) value : null;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     if (module != null) {
       setText(
           module.getName()
               + " ("
               + FileUtil.toSystemDependentName(module.getModuleFilePath())
               + ")");
     }
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   component.setEnabled(ProcessedModulesTable.this.isEnabled());
   if (component instanceof JLabel) {
     final Icon icon = module != null ? ModuleType.get(module).getIcon() : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
   return component;
 }
コード例 #5
0
 public static void main(String[] args) throws Exception {
   if (args.length > 0) {
     DATABASE_FILE = Paths.get(args[0]);
   }
   UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
   launch(args);
 }
コード例 #6
0
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   T t = (T) value;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     setText(t != null ? getItemText(t) : "");
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   final MyTableModel model = (MyTableModel) table.getModel();
   component.setEnabled(
       ElementsChooser.this.isEnabled()
           && (myColorUnmarkedElements ? model.isElementMarked(row) : true));
   final ElementProperties properties = myElementToPropertiesMap.get(t);
   if (component instanceof JLabel) {
     final Icon icon =
         properties != null ? properties.getIcon() : t != null ? getItemIcon(t) : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(
       properties != null && properties.getColor() != null
           ? properties.getColor()
           : (isSelected ? table.getSelectionForeground() : table.getForeground()));
   return component;
 }
コード例 #7
0
ファイル: mainForm.java プロジェクト: joseph-zhong/Outside
  /**
   * Main method. Begins the GUI, and the rest of the program.
   *
   * @param args the command line arguments
   */
  public static void main(String args[]) {
    // playSound();
    try {
      for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (ClassNotFoundException
        | InstantiationException
        | IllegalAccessException
        | UnsupportedLookAndFeelException ex) {
      Logger.getLogger(mainForm.class.getName()).log(Level.SEVERE, null, ex);
    }
    // </editor-fold>

    /* Create and display the form */
    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            new mainForm().setVisible(true);
          }
        });
  }
コード例 #8
0
ファイル: gui.java プロジェクト: psager/jobManager
 public static void main(String[] args) {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
     System.err.println("Look and feel not set.");
   }
   new gui();
 }
コード例 #9
0
 /*
  * (non-Javadoc)
  *
  * @see javax.swing.JPanel#updateUI()
  */
 @Override
 public void updateUI() {
   if (UIManager.get(getUIClassID()) != null) {
     setUI((BandControlPanelUI) UIManager.getUI(this));
   } else {
     setUI(new BasicFlowBandControlPanelUI());
   }
 }
コード例 #10
0
 public static void main(String[] args) {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
     String message = "ExceptionWhileSettingSystemLookAndFeel";
     Logging.logger().log(java.util.logging.Level.WARNING, message, e);
   }
   start("World Wind - elevations demo", AppFrame.class);
 }
コード例 #11
0
  /** 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);
  }
コード例 #12
0
 private ActionMap getActionMap() {
   ActionMap actionMap = (ActionMap) UIManager.get("Grid.actionMap");
   if (actionMap == null) {
     actionMap = createActionMap();
     if (actionMap != null) {
       UIManager.put("Grid.actionMap", actionMap);
     }
   }
   return actionMap;
 }
コード例 #13
0
 @Override
 protected void installDefaults() {
   UIManager.put("TabbedPane.selected", Color.BLACK);
   UIManager.put("TabbedPane.tabsOverlapBorder", true);
   super.installDefaults();
   tabInsets = new Insets(0, 0, 0, 0);
   contentBorderInsets = new Insets(0, 0, 0, 0);
   tabAreaInsets = new Insets(0, 0, 0, 0);
   selectedTabPadInsets = new Insets(0, 0, 0, 0);
 }
コード例 #14
0
ファイル: MultiLabel.java プロジェクト: philippsimon/JFritz
  public MultiLabel(String str, int horizontalAlignment, int textAlignment, int verticalAlignment) {
    this.setForeground(UIManager.getColor("Label.foreground"));
    this.setBackground(UIManager.getColor("Label.background"));
    this.setFont(UIManager.getFont("Label.font"));

    setText(str);
    this.horizontalAlignment = horizontalAlignment;
    this.textAlignment = textAlignment;
    this.verticalAlignment = verticalAlignment;
  }
コード例 #15
0
  /** Invoked via reflection. */
  LafManagerImpl() {
    myListenerList = new EventListenerList();

    List<UIManager.LookAndFeelInfo> lafList = ContainerUtil.newArrayList();

    if (SystemInfo.isMac) {
      if (Registry.is("ide.mac.yosemite.laf")
          && isIntelliJLafEnabled()
          && SystemInfo.isJavaVersionAtLeast("1.8")) {
        lafList.add(new UIManager.LookAndFeelInfo("Default", IntelliJLaf.class.getName()));
      } else {
        lafList.add(
            new UIManager.LookAndFeelInfo("Default", UIManager.getSystemLookAndFeelClassName()));
      }
    } else {
      if (isIntelliJLafEnabled()) {
        lafList.add(new IntelliJLookAndFeelInfo());
      } else {
        lafList.add(new IdeaLookAndFeelInfo());
      }
      for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
        String name = laf.getName();
        if (!"Metal".equalsIgnoreCase(name)
            && !"CDE/Motif".equalsIgnoreCase(name)
            && !"Nimbus".equalsIgnoreCase(name)
            && !"Windows Classic".equalsIgnoreCase(name)
            && !name.startsWith("JGoodies")) {
          lafList.add(laf);
        }
      }
    }

    lafList.add(new DarculaLookAndFeelInfo());

    myLaFs = lafList.toArray(new UIManager.LookAndFeelInfo[lafList.size()]);

    if (!SystemInfo.isMac) {
      // do not sort LaFs on mac - the order is determined as Default, Darcula.
      // when we leave only system LaFs on other OSes, the order also should be determined as
      // Default, Darcula

      Arrays.sort(
          myLaFs,
          new Comparator<UIManager.LookAndFeelInfo>() {
            @Override
            public int compare(UIManager.LookAndFeelInfo obj1, UIManager.LookAndFeelInfo obj2) {
              String name1 = obj1.getName();
              String name2 = obj2.getName();
              return name1.compareToIgnoreCase(name2);
            }
          });
    }

    myCurrentLaf = getDefaultLaf();
  }
コード例 #16
0
 protected void installDefaults(JFileChooser fc) {
   installIcons(fc);
   installStrings(fc);
   usesSingleFilePane = UIManager.getBoolean("FileChooser.usesSingleFilePane");
   readOnly = UIManager.getBoolean("FileChooser.readOnly");
   TransferHandler th = fc.getTransferHandler();
   if (th == null || th instanceof UIResource) {
     fc.setTransferHandler(defaultTransferHandler);
   }
   LookAndFeel.installProperty(fc, "opaque", Boolean.FALSE);
 }
コード例 #17
0
 /** PUBLIC: Open a browser on the profiles. */
 public static void browseProfiles(List<Profile> profiles) {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     ProfileBrowser aProfileBrowserFrame;
     aProfileBrowserFrame = new ProfileBrowser();
     aProfileBrowserFrame.setVisible(true);
     aProfileBrowserFrame.setProfiles(profiles);
   } catch (Throwable exception) {
     System.err.println("Exception occurred in main() of javax.swing.JPanel");
     exception.printStackTrace(System.out);
   }
 }
コード例 #18
0
  public void launch() {
    try {
      long time = System.nanoTime();
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

      monitor = new ProgressMonitor();
      monitor.setMaximum(5);

      updateState(BootstrapState.UPDATE_CHECK);
      {
        CountDownLatch latch = new CountDownLatch(2);
        runTask(TaskBootstrapUpdateCheck.class, latch);
        runTask(TaskInstallerUpdateCheck.class, latch);
        latch.await();
      }

      updateState(BootstrapState.LOAD_DEPENDENCIES);
      {
        runTask(TaskLoadDependencies.class);
      }

      updateState(BootstrapState.DOWNLOAD);
      {
        runTask(TaskDownload.class);
      }

      updateState(BootstrapState.SETUP_ENVIRONMENT);
      {
        runTask(TaskCheckJavaVersion.class);
        runTask(TaskBuildClasspath.class);
      }

      System.out.println(
          "Took " + ((System.nanoTime() - time) / 1000000f) + "ms to launch installer");
      updateState(BootstrapState.START_INSTALLER);
      {
        runTask(TaskLaunchInstaller.class);
      }

      updateState(BootstrapState.FINISHED);
    } catch (BootstrapException ex) {
      handleException(ex);
      System.exit(2);
    } catch (Exception ex) {
      handleException(ex);
      System.exit(-1);
    } finally {
      monitor.close();
    }
  }
コード例 #19
0
 private InputMap getInputMap(int condition) {
   if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
     return (InputMap) UIManager.get("Grid.ancestorInputMap");
   } else {
     return null;
   }
 }
コード例 #20
0
ファイル: HyperSearchResults.java プロジェクト: SELab/jEdit
 @Override
 public String convertValueToText(
     Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
   String s = super.convertValueToText(value, selected, expanded, leaf, row, hasFocus);
   String newProp = jEdit.getProperty(HIGHLIGHT_PROP);
   if (newProp == null || newProp.isEmpty()) return s;
   DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
   while (node != null && !(node.getUserObject() instanceof HyperSearchOperationNode)) {
     node = (DefaultMutableTreeNode) node.getParent();
   }
   if (node == null) return s;
   if (!newProp.equals(prop)) {
     prop = newProp;
     Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
     styleTag = HtmlUtilities.style2html(prop, f);
   }
   SearchMatcher matcher = ((HyperSearchOperationNode) node.getUserObject()).getSearchMatcher();
   int i = s.indexOf(": ");
   if (i > 0) i += 2;
   else i = 0;
   Match m;
   List<Integer> matches = new ArrayList<Integer>();
   while ((m = matcher.nextMatch(s.substring(i), true, true, true, false)) != null) {
     matches.add(i + m.start);
     matches.add(i + m.end);
     i += m.end;
   }
   return HtmlUtilities.highlightString(s, styleTag, matches);
 }
コード例 #21
0
  @SuppressWarnings("HardCodedStringLiteral")
  private boolean togglePopup(KeyEvent e) {
    final KeyStroke stroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers());
    final Object action = ((InputMap) UIManager.get("ComboBox.ancestorInputMap")).get(stroke);
    if ("selectNext".equals(action)) {
      if (!isPopupShowing()) {
        return true;
      } else {
        return false;
      }
    } else if ("togglePopup".equals(action)) {
      if (isPopupShowing()) {
        closePopup();
      } else {
        suggestCompletion(true, true);
      }
      return true;
    } else {
      final Keymap active = KeymapManager.getInstance().getActiveKeymap();
      final String[] ids = active.getActionIds(stroke);
      if (ids.length > 0 && IdeActions.ACTION_CODE_COMPLETION.equals(ids[0])) {
        suggestCompletion(true, true);
      }
    }

    return false;
  }
コード例 #22
0
 public void actionPerformed(ActionEvent ae) {
   String cname = nameF.getText().trim();
   int state = conditions[stateC.getSelectedIndex()];
   try {
     if (isSpecialCase(cname)) {
       handleSpecialCase(cname, state);
     } else {
       JComponent comp = (JComponent) Class.forName(cname).newInstance();
       ComponentUI cui = UIManager.getUI(comp);
       cui.installUI(comp);
       results.setText("Map entries for " + cname + ":\n\n");
       if (inputB.isSelected()) {
         loadInputMap(comp.getInputMap(state), "");
         results.append("\n");
       }
       if (actionB.isSelected()) {
         loadActionMap(comp.getActionMap(), "");
         results.append("\n");
       }
       if (bindingB.isSelected()) {
         loadBindingMap(comp, state);
       }
     }
   } catch (ClassCastException cce) {
     results.setText(cname + " is not a subclass of JComponent.");
   } catch (ClassNotFoundException cnfe) {
     results.setText(cname + " was not found.");
   } catch (InstantiationException ie) {
     results.setText(cname + " could not be instantiated.");
   } catch (Exception e) {
     results.setText("Exception found:\n" + e);
     e.printStackTrace();
   }
 }
コード例 #23
0
ファイル: HyperSearchResults.java プロジェクト: SELab/jEdit
    @Override
    public void actionPerformed(ActionEvent evt) {
      Object source = evt.getSource();
      if (source == highlight) {
        String prop = jEdit.getProperty(HIGHLIGHT_PROP);
        Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
        SyntaxStyle style =
            new StyleEditor(
                    jEdit.getActiveView(),
                    HtmlUtilities.parseHighlightStyle(prop, f),
                    "hypersearch")
                .getStyle();
        if (style != null) jEdit.setProperty(HIGHLIGHT_PROP, GUIUtilities.getStyleString(style));
        updateHighlightStatus();
      } else if (source == clear) {
        removeAllNodes();
      } else if (source == multi) {
        multiStatus = !multiStatus;
        updateMultiStatus();

        if (!multiStatus) {
          for (int i = resultTreeRoot.getChildCount() - 2; i >= 0; i--) {
            resultTreeModel.removeNodeFromParent((MutableTreeNode) resultTreeRoot.getChildAt(i));
          }
        }
      } else if (source == stop) {
        jEdit.setTemporaryProperty("hyperSearch-stopButton", "true");
      }
    }
コード例 #24
0
 private synchronized void dispose() {
   timer.stop();
   UIManager.removePropertyChangeListener(this);
   synchronized (AnimationController.class) {
     AppContext.getAppContext().put(ANIMATION_CONTROLLER_KEY, null);
   }
 }
コード例 #25
0
 /**
  * Update the Look and Feel of the game
  *
  * @param lnf fully qualified look and feel class name
  */
 private void changeLnF(String lnf) {
   try {
     UIManager.setLookAndFeel(lnf);
     SwingUtilities.updateComponentTreeUI(this);
   } catch (Exception e) {
   }
 }
コード例 #26
0
 public static void createAndShowGUI() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (ClassNotFoundException
       | InstantiationException
       | IllegalAccessException
       | UnsupportedLookAndFeelException ex) {
     ex.printStackTrace();
   }
   JFrame frame = new JFrame("@title@");
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   frame.getContentPane().add(new MainPanel());
   frame.pack();
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
コード例 #27
0
ファイル: Notepad.java プロジェクト: ArcherSys/ArcherSysRuby
  @SuppressWarnings("OverridableMethodCallInConstructor")
  Notepad() {
    super(true);

    // Trying to set Nimbus look and feel
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception ignored) {
    }

    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor = createEditor();
    // Add this as a listener for undoable edits.
    editor.getDocument().addUndoableEditListener(undoHandler);

    // install the command table
    commands = new HashMap<Object, Action>();
    Action[] actions = getActions();
    for (Action a : actions) {
      commands.put(a.getValue(Action.NAME), a);
    }

    JScrollPane scroller = new JScrollPane();
    JViewport port = scroller.getViewport();
    port.add(editor);

    String vpFlag = getProperty("ViewportBackingStore");
    if (vpFlag != null) {
      Boolean bs = Boolean.valueOf(vpFlag);
      port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE);
    }

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add("North", createToolbar());
    panel.add("Center", scroller);
    add("Center", panel);
    add("South", createStatusbar());
  }
コード例 #28
0
 @Override
 public String getAccessibleActionDescription(int i) {
   if (i == 0) {
     return UIManager.getString("AbstractButton.clickText");
   } else {
     return null;
   }
 }
コード例 #29
0
ファイル: JSlider.java プロジェクト: CodeingBoy/Java8CN
 /**
  * Resets the UI property to a value from the current look and feel.
  *
  * @see JComponent#updateUI
  */
 public void updateUI() {
   setUI((SliderUI) UIManager.getUI(this));
   // The labels preferred size may be derived from the font
   // of the slider, so we must update the UI of the slider first, then
   // that of labels.  This way when setSize is called the right
   // font is used.
   updateLabelUIs();
 }
コード例 #30
0
 /** Switch to a new Look&Feel */
 private void newLookAndFeel(String landf) {
   try {
     UIManager.setLookAndFeel(landf);
     SwingUtilities.updateComponentTreeUI(this);
   } catch (Exception e) {
     System.err.println(e);
   }
 }