예제 #1
0
 /** Sanity: icons updated on LF change. */
 public void testTreeIconsUpdateUI() {
   JXTree tree = new JXTree();
   DefaultTreeRenderer renderer = new DefaultTreeRenderer();
   tree.setCellRenderer(renderer);
   WrappingIconPanel before =
       (WrappingIconPanel)
           renderer.getTreeCellRendererComponent(tree, "", false, false, true, -1, false);
   Icon leaf = before.getIcon();
   assertNotNull("sanity", leaf);
   assertEquals("sanity", UIManager.getIcon("Tree.leafIcon"), leaf);
   String lf = UIManager.getLookAndFeel().getName();
   setSystemLF(!defaultToSystemLF);
   if (lf.equals(UIManager.getLookAndFeel().getName())) {
     LOG.info("cannot run test - equal LF" + lf);
     return;
   }
   SwingUtilities.updateComponentTreeUI(tree);
   WrappingIconPanel after =
       (WrappingIconPanel)
           renderer.getTreeCellRendererComponent(tree, "", false, false, true, -1, false);
   Icon leafAfter = after.getIcon();
   assertNotNull("sanity", leafAfter);
   assertFalse("sanity", leaf.equals(leafAfter));
   assertEquals("icon must be updated", UIManager.getIcon("Tree.leafIcon"), leafAfter);
 }
예제 #2
0
 public MyRenderComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
   super();
   this.table = table;
   this.col = col;
   if (value != null) {
     setText(value.toString());
   } else {
     setText("");
   }
   setOpaque(false);
   setFont(UIManager.getFont("TableHeader.font"));
   setForeground(UIManager.getColor("TableHeader.foreground"));
   setHorizontalAlignment(JLabel.CENTER);
   setHorizontalTextPosition(SwingConstants.LEADING);
   setBorder(UIManager.getBorder("TableHeader.cellBorder"));
   if ((JTattooUtilities.getJavaVersion() >= 1.6)
       && (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel)) {
     RowSorter rowSorter = table == null ? null : table.getRowSorter();
     List keyList = rowSorter == null ? null : rowSorter.getSortKeys();
     if ((keyList != null) && (keyList.size() > 0)) {
       RowSorter.SortKey sortKey = (RowSorter.SortKey) keyList.get(0);
       if (sortKey.getColumn() == table.convertColumnIndexToModel(col)) {
         AbstractIconFactory iconFactory =
             ((AbstractLookAndFeel) UIManager.getLookAndFeel()).getIconFactory();
         if (sortKey.getSortOrder().equals(SortOrder.ASCENDING)) {
           setIcon(iconFactory.getUpArrowIcon());
         } else if (sortKey.getSortOrder().equals(SortOrder.DESCENDING)) {
           setIcon(iconFactory.getDownArrowIcon());
         }
       }
     }
   }
   gv = ColorHelper.getGrayValue(AbstractLookAndFeel.getTheme().getRolloverColor());
 }
예제 #3
0
 private Object[] buttons() {
   ResourceBundle bundle = NbBundle.getBundle(PropertyAction.class);
   JButton okButton = new JButton();
   Mnemonics.setLocalizedText(okButton, bundle.getString("CTL_OK")); // NOI18N
   okButton
       .getAccessibleContext()
       .setAccessibleDescription(bundle.getString("ACSD_CTL_OK")); // NOI18N
   okButton.setActionCommand(OK_COMMAND);
   JButton cancelButton = new JButton();
   Mnemonics.setLocalizedText(cancelButton, bundle.getString("CTL_Cancel")); // NOI18N
   cancelButton
       .getAccessibleContext()
       .setAccessibleDescription(bundle.getString("ACSD_CTL_Cancel")); // NOI18N
   cancelButton.setActionCommand(CANCEL_COMMAND);
   if (property.isDefaultValue()) {
     if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
       return new Object[] {cancelButton, okButton};
     } else {
       return new Object[] {okButton, cancelButton};
     }
   } else {
     JButton restoreButton = new JButton();
     Mnemonics.setLocalizedText(restoreButton, bundle.getString("CTL_RestoreDefault")); // NOI18N
     restoreButton
         .getAccessibleContext()
         .setAccessibleDescription(bundle.getString("ACSD_CTL_RestoreDefault")); // NOI18N
     restoreButton.setActionCommand(RESTORE_COMMAND);
     if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
       return new Object[] {restoreButton, cancelButton, okButton};
     } else {
       return new Object[] {okButton, restoreButton, cancelButton};
     }
   }
 }
예제 #4
0
 public Icon getThumbVerIconRollover() {
   if (UIManager.getLookAndFeel() instanceof AbstractLookAndFeel) {
     return ((AbstractLookAndFeel) UIManager.getLookAndFeel())
         .getIconFactory()
         .getThumbVerIconRollover();
   }
   return null;
 }
예제 #5
0
 /** Returns whether the current LAF is Metal Steel. */
 protected static boolean isMetalSteel() {
   if (!UIManager.getLookAndFeel().getName().equals("Metal")) {
     return false;
   }
   try {
     LookAndFeel laf = UIManager.getLookAndFeel();
     laf.getClass().getMethod("getCurrentTheme", new Class[0]);
     return false;
   } catch (Exception e) {
   }
   return true;
 }
예제 #6
0
 public Dimension getPreferredSize(JComponent c) {
   Dimension size = super.getPreferredSize(c);
   if (comboBox.getGraphics() != null) {
     FontMetrics fm =
         Utilities.getFontMetrics(comboBox, comboBox.getGraphics(), comboBox.getFont());
     size.height = fm.getHeight() + 2;
     if (UIManager.getLookAndFeel() instanceof BaseLookAndFeel) {
       BaseLookAndFeel laf = (BaseLookAndFeel) UIManager.getLookAndFeel();
       size.height =
           Math.max(size.height, laf.getIconFactory().getDownArrowIcon().getIconHeight() + 2);
     }
   }
   return new Dimension(size.width + 2, size.height + 2);
 }
 public void insertString(int pOffs, String str, AttributeSet a) throws BadLocationException {
   int offs = pOffs;
   // return immediately when selecting an item
   if (selecting) return;
   // insert the string into the document
   super.insertString(offs, str, a);
   // lookup and select a matching item
   LookupResult lookupResult = lookupItem(getText(0, getLength()));
   if (lookupResult.matchingItem != null) {
     setSelectedItem(lookupResult.matchingItem, lookupResult.matchingString);
   } else {
     if (strictMatching) {
       // keep old item selected if there is no match
       lookupResult.matchingItem = adaptor.getSelectedItem();
       lookupResult.matchingString = adaptor.getSelectedItemAsString();
       // imitate no insert (later on offs will be incremented by
       // str.length(): selection won't move forward)
       offs = offs - str.length();
       // provide feedback to the user that his input has been received but can
       // not be accepted
       UIManager.getLookAndFeel().provideErrorFeedback(adaptor.getTextComponent());
     } else {
       // no item matches => use the current input as selected item
       lookupResult.matchingItem = getText(0, getLength());
       lookupResult.matchingString = getText(0, getLength());
       setSelectedItem(lookupResult.matchingItem, lookupResult.matchingString);
     }
   }
   setText(lookupResult.matchingString);
   // select the completed part
   adaptor.markText(offs + str.length());
 }
예제 #8
0
  @Override
  protected void addWindowsDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
    super.addWindowsDefaults(addon, defaults);

    defaults.add("SearchField.promptFontStyle", Font.ITALIC);
    defaults.add("SearchField.layoutStyle", LayoutStyle.VISTA);
    defaults.add("SearchField.icon", getIcon("windows/resources/search.gif"));
    defaults.add("SearchField.rolloverIcon", getIcon("windows/resources/search_rollover.gif"));
    defaults.add("SearchField.pressedIcon", getIcon("windows/resources/search_pressed.gif"));
    defaults.add("SearchField.popupIcon", getIcon("windows/resources/search_popup.gif"));
    defaults.add(
        "SearchField.popupRolloverIcon", getIcon("windows/resources/search_popup_rollover.gif"));
    defaults.add(
        "SearchField.popupPressedIcon", getIcon("windows/resources/search_popup_pressed.gif"));
    defaults.add("SearchField.clearIcon", getIcon("windows/resources/clear.gif"));
    defaults.add("SearchField.clearRolloverIcon", getIcon("windows/resources/clear_rollover.gif"));
    defaults.add("SearchField.clearPressedIcon", getIcon("windows/resources/clear_pressed.gif"));
    defaults.add("SearchField.useSeperatePopupButton", Boolean.TRUE);
    defaults.add("SearchField.popupOffset", -1);

    // Do it like 'Windows Media Player' in XP:
    // Replace the border line with the search button line on rollover.
    // But not in classic mode!
    if (UIManager.getLookAndFeel().getClass().getName().indexOf("Classic") == -1) {
      defaults.add("SearchField.buttonMargin", new InsetsUIResource(0, -1, 0, -1));
    } else {
      defaults.add("SearchField.buttonMargin", new InsetsUIResource(0, 0, 0, 0));
    }
  }
예제 #9
0
  public Object getValue() {
    String text = ((JTextField) editor).getText();
    if (text == null || text.trim().length() == 0) {
      return getDefaultValue();
    }

    // collect all numbers from this textfield
    StringBuffer number = new StringBuffer();
    number.ensureCapacity(text.length());
    for (int i = 0, c = text.length(); i < c; i++) {
      char character = text.charAt(i);
      if ('.' == character
          || '-' == character
          || 'E' == character
          || Character.isDigit(character)) {
        number.append(character);
      } else if (' ' == character) {
        continue;
      } else {
        break;
      }
    }

    try {
      lastGoodValue = Double.parseDouble(number.toString());
    } catch (Exception e) {
      UIManager.getLookAndFeel().provideErrorFeedback(editor);
    }

    return lastGoodValue;
  }
예제 #10
0
  public static int getNimbusFontSize() {
    Preferences p = Preferences.userNodeForPackage(ThemeManager.class);

    int preferredSize = p.getInt(NIMBUS_FONT_SIZE, 0);

    // if the returned value is zero, determine the default base font size
    // and save it
    if (preferredSize == 0) {

      LookAndFeel old = UIManager.getLookAndFeel();

      try {
        UIManager.setLookAndFeel(new NimbusLookAndFeel());
        preferredSize = NimbusUtils.getBaseFontSize();

        p.putInt(NIMBUS_FONT_SIZE, preferredSize);

        UIManager.setLookAndFeel(old);
      } catch (Exception e) {
        Logger.getLogger(ThemeManager.class.getName()).log(Level.SEVERE, e.toString(), e);
      }
    }

    return preferredSize;
  }
예제 #11
0
  /**
   * Loads the menu with the available look and feels for the application
   *
   * @return l and f menu
   */
  JMenu buildLookAndFeelMenu() {
    String activeLookAndFeelName = UIManager.getLookAndFeel().getName();

    // ButtonGroup buttonGroup = new ButtonGroup();
    JMenu lfMenu = new JMenu();

    lfMenu.setText(rb.getString("Menu.LookAndFeel.Name"));
    lfMenu.setMnemonic(jgnash.ui.util.Resource.getMnemonic("Menu.LookAndFeel.Mnemonic"));

    lfMenu.add(buildSubstanceMenu());

    List<String> lookAndFeels = new ArrayList<>();

    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
      if (isLookAndFeelAvailable(info.getClassName())) {
        lookAndFeels.add(info.getClassName());
      }
    }

    for (String lookAndFeel : KNOWN) {
      if (isLookAndFeelAvailable(lookAndFeel)) {
        lookAndFeels.add(lookAndFeel);
      }
    }

    Collections.sort(lookAndFeels);

    for (String lookAndFeel : lookAndFeels) {
      try {
        Class<?> lnfClass = Class.forName(lookAndFeel);
        LookAndFeel newLAF = (LookAndFeel) lnfClass.newInstance();

        JRadioButtonMenuItem button = new JRadioButtonMenuItem();

        button.setText(newLAF.getName());
        button.setActionCommand(lookAndFeel);
        button.setName(newLAF.getName());

        button.addActionListener(
            e -> {
              Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
              pref.put(LF, e.getActionCommand());

              restartUI();
            });

        lfButtonGroup.add(button);

        lfMenu.add(button);

        if (newLAF.getName().equals(activeLookAndFeelName)) {
          button.setSelected(true);
        }
      } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e);
      }
    }

    return lfMenu;
  }
예제 #12
0
  protected JComponent createLookAndFeelControl() {
    JPanel panel = new JPanel();

    JLabel label = new JLabel("Current Look and Feel");
    lookAndFeelComboBox = new JComboBox();
    label.setLabelFor(lookAndFeelComboBox);
    panel.add(label);
    panel.add(lookAndFeelComboBox);

    // Look for toolkit look and feels first
    UIManager.LookAndFeelInfo lookAndFeelInfos[] = UIManager.getInstalledLookAndFeels();
    lookAndFeelsMap = new HashMap<String, String>();
    for (UIManager.LookAndFeelInfo info : lookAndFeelInfos) {
      String name = info.getName();
      // workaround for problem where Info and name property don't match on OS X
      if (name.equals("Mac OS X")) {
        name = OSXLookAndFeelName;
      }
      // workaround for bug where Nimbus classname is incorrect
      lookAndFeelsMap.put(
          name,
          name.equals("Nimbus")
              ? "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"
              : info.getClassName());
      lookAndFeelComboBox.addItem(name);
    }
    lookAndFeelComboBox.setSelectedItem(UIManager.getLookAndFeel().getName());
    lookAndFeelComboBox.addActionListener(new ChangeLookAndFeelAction());

    return panel;
  }
예제 #13
0
  public void setLookAndFeel() {
    String lookAndFeel = ControlMain.getSettings().getMainSettings().getLookAndFeel();
    String current = UIManager.getLookAndFeel().getClass().getName();
    boolean lfChanged = !current.equals(lookAndFeel);

    try {
      boolean themeChanged = this.isPlasticThemeChanged();
      if (themeChanged) {
        PlasticTheme inst =
            (PlasticTheme)
                (Class.forName(
                        "com.jgoodies.looks.plastic.theme."
                            + ControlMain.getSettings().getMainSettings().getPlasticTheme()))
                    .newInstance();
        PlasticLookAndFeel.setCurrentTheme(inst);
      }

      if (lfChanged || themeChanged) {
        UIManager.setLookAndFeel(lookAndFeel);
        if (lookAndFeel.indexOf("WindowsLookAndFeel") > -1
            || lookAndFeel.indexOf("WindowsClassicLookAndFeel") > -1) {
          UIManager.put("TextArea.font", new Font("Tahoma", Font.PLAIN, 11));
        }
        if (this.getView() != null) {
          this.getView().repaintGui();
        }
      }
    } catch (Exception e) {
      Logger.getLogger("ControlMainView").warning(e.getMessage());
    }
  }
예제 #14
0
 /**
  * Replaces the currently selected content with new content represented by the given StyledText.
  * If there is no selection this amounts to an insert of the given text. If there is no
  * replacement text this amounts to a removal of the current selection. The replacement text will
  * have the attributes currently defined for input at the point of insertion. If the document is
  * not editable, beep and return
  *
  * @param content the content to replace the selection with
  * @see StyledText#insert
  */
 public static void replaceSelection(Word word, StyledText content) {
   Document doc = word.workspace.getDocument();
   String text;
   Caret caret = word.workspace.getCaret();
   int insertPos = 0;
   int i;
   int contentSize;
   if (doc != null) {
     try {
       int p0 = Math.min(caret.getDot(), caret.getMark());
       int p1 = Math.max(caret.getDot(), caret.getMark());
       // if there is any selection
       if (p0 != p1) {
         doc.remove(p0, p1 - p0);
       }
       // insert the content
       if (content != null) {
         content.insert(doc, p0);
       }
     } catch (BadLocationException ble) {
       javax.swing.UIManager.getLookAndFeel().provideErrorFeedback(word.workspace);
       return;
     }
   }
 }
예제 #15
0
  /**
   * Creates UI with Look and Feel defined in UIManager
   *
   * @param c
   * @return Component
   */
  public static ComponentUI createUI(JComponent c) {
    String componentName = c.getClass().getName();

    int index = componentName.lastIndexOf('.') + 1;
    StringBuffer sb = new StringBuffer();
    sb.append(componentName.substring(0, index));

    String lookAndFeelName = UIManager.getLookAndFeel().getName();
    if (lookAndFeelName.startsWith("CDE/")) {
      lookAndFeelName = lookAndFeelName.substring(4, lookAndFeelName.length());
    }
    sb.append(lookAndFeelName);
    sb.append(componentName.substring(index));
    sb.append("UI");

    ComponentUI componentUI = getInstance(sb.toString());

    if (componentUI == null) {
      sb.setLength(0);
      sb.append(componentName.substring(0, index));
      sb.append("Basic");
      sb.append(componentName.substring(index));
      sb.append("UI");
      componentUI = getInstance(sb.toString());
    }

    return componentUI;
  }
 /** 当前的外观保存到配置文件 */
 public static void saveConfig() {
   try {
     String s = UIManager.getLookAndFeel().getClass().getName();
     if (s != null) saveConfig(s);
   } catch (IOException e) {
   }
 }
예제 #17
0
파일: Apps.java 프로젝트: dpharris/JMRI
  /**
   * Create default File menu
   *
   * @param menuBar Menu bar to be populated
   * @param wi WindowInterface where this menu will appear as part of the menu bar
   */
  protected void fileMenu(JMenuBar menuBar, WindowInterface wi) {
    JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
    menuBar.add(fileMenu);

    fileMenu.add(
        new PrintDecoderListAction(
            Bundle.getMessage("MenuPrintDecoderDefinitions"), wi.getFrame(), false));
    fileMenu.add(
        new PrintDecoderListAction(
            Bundle.getMessage("MenuPrintPreviewDecoderDefinitions"), wi.getFrame(), true));

    // Use Mac OS X native Quit if using Aqua look and feel
    if (!(SystemType.isMacOSX() && UIManager.getLookAndFeel().isNativeLookAndFeel())) {
      fileMenu.add(new JSeparator());
      fileMenu.add(
          new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
            /** */
            private static final long serialVersionUID = -3051429826192051394L;

            @Override
            public void actionPerformed(ActionEvent e) {
              handleQuit();
            }
          });
    }
  }
예제 #18
0
  public static final LookAndFeelType getLAF() {
    if (lookAndFeelType == null) {
      try {
        initializeLookAndFeel();
      } catch (InitializationException e) {
        LogManager.log(e);
      }
      lookAndFeelType = LookAndFeelType.DEFAULT;

      if (UiMode.getCurrentUiMode() == UiMode.SWING) {
        LookAndFeel laf = UIManager.getLookAndFeel();
        if (laf != null) {
          String id = laf.getID();
          for (LookAndFeelType type : LookAndFeelType.values()) {
            if (id.equals(LookAndFeelType.WINDOWS_XP.getId())
                || id.equals(LookAndFeelType.WINDOWS_CLASSIC.getId())) {
              final Object object =
                  Toolkit.getDefaultToolkit().getDesktopProperty(WINDOWS_XP_THEME_MARKER_PROPERTY);
              boolean xpThemeActive = false;
              if (object != null) {
                xpThemeActive = (Boolean) object;
              }
              lookAndFeelType =
                  (xpThemeActive) ? LookAndFeelType.WINDOWS_XP : LookAndFeelType.WINDOWS_CLASSIC;
              break;
            } else if (id.equals(type.getId())) {
              lookAndFeelType = type;
              break;
            }
          }
        }
      }
    }
    return lookAndFeelType;
  }
예제 #19
0
  @SuppressWarnings("unchecked")
  static <C extends JComponent & BackgroundPaintable> void paintBackground(C comp, Graphics2D g) {
    // we should be painting the background behind the painter if we have one
    // this prevents issues with buffer reuse where visual artifacts sneak in
    if (comp.isOpaque()
        || (comp instanceof AlphaPaintable && ((AlphaPaintable) comp).getAlpha() < 1f)
        || UIManager.getLookAndFeel().getID().equals("Nimbus")) {
      g.setColor(comp.getBackground());
      g.fillRect(0, 0, comp.getWidth(), comp.getHeight());
    }

    Painter<? super C> painter = comp.getBackgroundPainter();

    if (painter != null) {
      if (comp.isPaintBorderInsets()) {
        painter.paint(g, comp, comp.getWidth(), comp.getHeight());
      } else {
        Insets insets = comp.getInsets();
        g.translate(insets.left, insets.top);
        painter.paint(
            g,
            comp,
            comp.getWidth() - insets.left - insets.right,
            comp.getHeight() - insets.top - insets.bottom);
        g.translate(-insets.left, -insets.top);
      }
    }
  }
예제 #20
0
  private void flipSeparators(Component c, int orientn) {

    if (c != null
        && c instanceof JToolBar
        && UIManager.getLookAndFeel().getName().toLowerCase().indexOf("windows") != -1) {

      JToolBar jtb = (JToolBar) c;

      Component comps[] = jtb.getComponents();

      if (comps != null && comps.length > 0) {

        for (int i = 0; i < comps.length; i++) {

          try {

            Component component = comps[i];

            if (component != null) {

              if (component instanceof JSeparator) {

                jtb.remove(component);

                JSeparator separ = new JSeparator();

                if (orientn == SwingConstants.VERTICAL) {

                  separ.setOrientation(SwingConstants.VERTICAL);

                  separ.setMinimumSize(new Dimension(2, 6));

                  separ.setPreferredSize(new Dimension(2, 6));

                  separ.setMaximumSize(new Dimension(2, 100));

                } else {

                  separ.setOrientation(SwingConstants.HORIZONTAL);

                  separ.setMinimumSize(new Dimension(6, 2));

                  separ.setPreferredSize(new Dimension(6, 2));

                  separ.setMaximumSize(new Dimension(100, 2));
                }

                jtb.add(separ, i);
              }
            }

          } catch (Exception e) {

            e.printStackTrace();
          }
        }
      }
    }
  }
 private HistoryTopComponent() {
   initComponents();
   if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { // NOI18N
     setBackground(UIManager.getColor("NbExplorerView.background")); // NOI18N
   }
   setToolTipText(
       NbBundle.getMessage(HistoryTopComponent.class, "HINT_LocalHistoryTopComponent")); // NOI18N
 }
예제 #22
0
 /** Ensures that the phantom text field has a Plastic text field UI. */
 private static void ensurePhantomHasPlasticUI() {
   TextUI ui = PHANTOM.getUI();
   Class lafClass = UIManager.getLookAndFeel().getClass();
   if ((phantomLafClass != lafClass) || !(ui instanceof MetalTextFieldUI)) {
     phantomLafClass = lafClass;
     PHANTOM.updateUI();
   }
 }
예제 #23
0
  public void initUI() {
    scrollingToBottomCheckbox.setSelected(applicationPreferences.isScrollingToBottom());
    coloringWholeRowCheckbox.setSelected(applicationPreferences.isColoringWholeRow());
    showFullCallstackCheckbox.setSelected(applicationPreferences.isShowingFullCallstack());
    showStackTraceCheckbox.setSelected(applicationPreferences.isShowingStackTrace());
    usingWrappedExceptionStyleCheckbox.setSelected(
        applicationPreferences.isUsingWrappedExceptionStyle());

    // look and feel
    {
      ArrayList<String> lookAndFeels = new ArrayList<>();
      for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        lookAndFeels.add(info.getName());
      }
      Collections.sort(lookAndFeels);
      int selectedIndex = 0;
      String lookAndFeel = applicationPreferences.getLookAndFeel();
      if (lookAndFeel == null || "".equals(lookAndFeel)) {
        lookAndFeel = UIManager.getLookAndFeel().getName();
      }
      int idx = lookAndFeels.indexOf(lookAndFeel);
      if (idx > -1) {
        selectedIndex = idx;
      } else {
        idx = lookAndFeels.indexOf(ApplicationPreferences.STARTUP_LOOK_AND_FEEL);
        if (idx > -1) {
          selectedIndex = idx;
        }
      }
      lookAndFeelCombo.setModel(
          new DefaultComboBoxModel<>(lookAndFeels.toArray(new String[lookAndFeels.size()])));
      lookAndFeelCombo.setSelectedIndex(selectedIndex);
    }

    // default condition name
    {
      List<String> conditionNames = applicationPreferences.retrieveAllConditions();
      String defaultName = applicationPreferences.getDefaultConditionName();
      int idx = conditionNames.indexOf(defaultName);
      if (idx < 0) {
        idx = 0;
      }

      defaultConditionCombo.setModel(
          new DefaultComboBoxModel<>(conditionNames.toArray(new String[conditionNames.size()])));
      defaultConditionCombo.setSelectedIndex(idx);
    }
    String appPath = applicationPreferences.getApplicationPath().getAbsolutePath();
    appPathTextField.setText(appPath);
    appPathTextField.setToolTipText(appPath);

    globalLoggingEnabledCheckbox.setSelected(applicationPreferences.isGlobalLoggingEnabled());
    loggingStatsEnabledCheckbox.setSelected(applicationPreferences.isLoggingStatisticEnabled());
    trayActiveCheckbox.setSelected(applicationPreferences.isTrayActive());
    trayActiveCheckbox.setEnabled(TraySupport.isAvailable());
    hidingOnCloseCheckbox.setSelected(applicationPreferences.isHidingOnClose());
    hidingOnCloseCheckbox.setEnabled(TraySupport.isAvailable());
  }
 /** Creates a disabled checkbox icon. */
 private static Icon createDisabledIcon(JCheckBox checkBox, Icon icon) {
   Image image =
       new BufferedImage(icon.getIconWidth(), icon.getIconWidth(), BufferedImage.TYPE_INT_RGB);
   Graphics g = image.getGraphics();
   checkBox.setSelected(true);
   icon.paintIcon(checkBox, g, 0, 0);
   g.dispose();
   return UIManager.getLookAndFeel().getDisabledIcon(checkBox, new ImageIcon(image));
 }
 /** Returns the value from the desktop. */
 protected Object getValueFromDesktop() {
   if (this.toolkit == null) {
     this.toolkit = Toolkit.getDefaultToolkit();
   }
   Object value = toolkit.getDesktopProperty(getKey());
   pcl = new WeakPCL(this, toolkit, getKey(), UIManager.getLookAndFeel());
   toolkit.addPropertyChangeListener(getKey(), pcl);
   return value;
 }
예제 #26
0
 /**
  * Copies the full path of the selected file to the clipboard.
  *
  * @return Whether the selected tree node was a file. If this is <code>null</code>, the clipboard
  *     was not updated.
  */
 protected boolean copySelectedFilePathToClipboard() {
   File file = getSelectedFile();
   if (file != null && file.exists()) {
     StringSelection sel = new StringSelection(file.getAbsolutePath());
     Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel);
     return true;
   }
   UIManager.getLookAndFeel().provideErrorFeedback(this);
   return false;
 }
예제 #27
0
  public static boolean isNativeMacLookAndFeel() {

    if (!isMac()) {

      return false;
    }

    String laf = UIManager.getLookAndFeel().getClass().getName();
    return (laf.equals(UIManager.getSystemLookAndFeelClassName()));
  }
예제 #28
0
  /** Provide appropriate LAF feedback when a filter error occurs. */
  public void provideErrorFeedback() {
    LookAndFeel laf = UIManager.getLookAndFeel();

    if (laf == null) {
      Toolkit.getDefaultToolkit().beep();
    } else {
      KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      Component component = fm.getFocusOwner();
      laf.provideErrorFeedback(component);
    }
  }
예제 #29
0
    @Override
    public void update(AnActionEvent e) {
      super.update(e);

      boolean enabled = isEnabled();
      Icon icon = enabled ? myIcon : UIManager.getLookAndFeel().getDisabledIcon(null, myIcon);
      if (icon == null) {
        icon = myIcon;
      }
      e.getPresentation().setIcon(icon);
    }
예제 #30
-1
 public static boolean isMacNativeLookAndFeel() {
   if (AppProperties.OPERATING_SYSTEM.startsWith("mac")) { // $NON-NLS-1$
     LookAndFeel laf = javax.swing.UIManager.getLookAndFeel();
     if (laf != null && laf.isNativeLookAndFeel()) {
       return true;
     }
   }
   return false;
 }