Пример #1
0
 public void actionPerformed(ActionEvent evt) {
   Component parent = extensionButton.getParent();
   while ((parent != null) && !(parent instanceof Frame)) parent = parent.getParent();
   String newExtensions =
       JOptionPane.showInputDialog(
           parent,
           "Edit the extension list.\nSeparate extensions by commas.\n\n",
           filter.getExtensionString());
   if ((newExtensions != null) && !newExtensions.trim().equals("")) {
     newExtensions = newExtensions.replaceAll("\\s", "");
     filter.setExtensions(newExtensions);
     extensionButton.setText(filter.getDescription());
     properties.setProperty("extensions", filter.getExtensionString());
     directoryPane.reloadTree();
   }
 }
Пример #2
0
  /**
   * Returns the <code>GTKStyle</code> to use based on the <code>Region</code> id
   *
   * @param c this parameter isn't used, may be null.
   * @param id of the region to get the style.
   */
  public synchronized SynthStyle getStyle(JComponent c, Region id) {
    WidgetType wt = GTKNativeEngine.getWidgetType(c, id);

    Object key = null;
    if (id == Region.SCROLL_BAR) {
      // The style/insets of a scrollbar can depend on a number of
      // factors (see GTKStyle.getScrollBarInsets()) so use a
      // complex key here.
      if (c != null) {
        JScrollBar sb = (JScrollBar) c;
        boolean sp = (sb.getParent() instanceof JScrollPane);
        boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL);
        boolean ltr = sb.getComponentOrientation().isLeftToRight();
        boolean focusable = sb.isFocusable();
        key = new ComplexKey(wt, sp, horiz, ltr, focusable);
      }
    } else if (id == Region.CHECK_BOX || id == Region.RADIO_BUTTON) {
      // The style/insets of a checkbox or radiobutton can depend
      // on the component orientation, so use a complex key here.
      if (c != null) {
        boolean ltr = c.getComponentOrientation().isLeftToRight();
        key = new ComplexKey(wt, ltr);
      }
    } else if (id == Region.BUTTON) {
      // The style/insets of a button can depend on whether it is
      // default capable or in a toolbar, so use a complex key here.
      if (c != null) {
        JButton btn = (JButton) c;
        boolean toolButton = (btn.getParent() instanceof JToolBar);
        boolean defaultCapable = btn.isDefaultCapable();
        key = new ComplexKey(wt, toolButton, defaultCapable);
      }
    }
    if (key == null) {
      // Otherwise, just use the WidgetType as the key.
      key = wt;
    }

    GTKStyle result = stylesCache.get(key);
    if (result == null) {
      result = isNativeGtk ? new GTKNativeStyle(defaultFont, wt) : new GTKDefaultStyle(defaultFont);
      stylesCache.put(key, result);
    }

    return result;
  }