Beispiel #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);
 }
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {

      setFont(tree.getFont());
      String stringValue = tree.convertValueToText(value, sel, expanded, leaf, row, hasFocus);

      setEnabled(tree.isEnabled());
      setText(stringValue);
      if (sel) setForeground(Color.blue);
      else setForeground(Color.black);
      if (leaf) {
        setIcon(UIManager.getIcon("Tree.leafIcon"));
      } else if (expanded) {
        setIcon(UIManager.getIcon("Tree.openIcon"));
      } else {
        setIcon(UIManager.getIcon("Tree.closedIcon"));
      }
      return this;
    }
Beispiel #3
0
 /*      */ private void createButtons() /*      */ {
   /*  499 */ this.closeButton = createTitleButton();
   /*  500 */ this.closeButton.setAction(this.closeAction);
   /*  501 */ this.closeButton.setText(null);
   /*  502 */ this.closeButton.putClientProperty("paintActive", Boolean.TRUE);
   /*  503 */ this.closeButton.setBorder(handyEmptyBorder);
   /*  504 */ this.closeButton.putClientProperty("AccessibleName", "Close");
   /*      */
   /*  506 */ this.closeButton.setIcon(UIManager.getIcon("InternalFrame.closeIcon"));
   /*      */
   /*  508 */ if (getWindowDecorationStyle() == 1) {
     /*  509 */ this.maximizeIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
     /*  510 */ this.minimizeIcon = UIManager.getIcon("InternalFrame.minimizeIcon");
     /*      */
     /*  512 */ this.iconifyButton = createTitleButton();
     /*  513 */ this.iconifyButton.setAction(this.iconifyAction);
     /*  514 */ this.iconifyButton.setText(null);
     /*  515 */ this.iconifyButton.putClientProperty("paintActive", Boolean.TRUE);
     /*  516 */ this.iconifyButton.setBorder(handyEmptyBorder);
     /*  517 */ this.iconifyButton.putClientProperty("AccessibleName", "Iconify");
     /*      */
     /*  519 */ this.iconifyButton.setIcon(UIManager.getIcon("InternalFrame.iconifyIcon"));
     /*      */
     /*  521 */ this.toggleButton = createTitleButton();
     /*  522 */ this.toggleButton.setAction(this.restoreAction);
     /*  523 */ this.toggleButton.putClientProperty("paintActive", Boolean.TRUE);
     /*  524 */ this.toggleButton.setBorder(handyEmptyBorder);
     /*  525 */ this.toggleButton.putClientProperty("AccessibleName", "Maximize");
     /*      */
     /*  527 */ this.toggleButton.setIcon(this.maximizeIcon);
     /*      */ }
   /*      */ }
 /** @return the default warning icon */
 protected Icon getDefaultWarningIcon() {
   try {
     Icon icon = UIManager.getIcon(CLASS_NAME + ".warningIcon");
     return icon == null ? UIManager.getIcon("OptionPane.warningIcon") : icon;
   } catch (Exception e) {
     return null;
   }
 }
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean selected,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {
    jl.setFont(tree.getFont());

    /*
     * Icons are *important*; this is (obviously) wholly inadequate ATM.
     * Individual programs should have their own icons, where possible
     * (ideally, favicons from main site pages). Seasons
     * could use Apple-alias-style derived icons, or something.
     */

    if (leaf) {
      jl.setIcon(UIManager.getIcon("Tree.leafIcon"));
    } else if (expanded) {
      jl.setIcon(UIManager.getIcon("Tree.openIcon"));
    } else {
      jl.setIcon(UIManager.getIcon("Tree.closedIcon"));
    }

    //        this.value = value.toString();
    jl.setText(value.toString());
    jl.setForeground(Color.BLACK);

    Checkable c = (Checkable) value;

    this.implicit = c.implicit;
    this.selected = c.isSelected();

    if (c instanceof EpisodeTreeNode) {
      EpisodeTreeNode n = (EpisodeTreeNode) c;
      if (n.icon != null) jl.setIcon(n.icon);
    }

    if (c.isLocal) {
      jl.setFont(jl.getFont().deriveFont(Font.BOLD));
    }

    if (c.isPartiallyLocal) {
      jl.setForeground(Color.BLUE);
    } else if (selected) {
      jl.setForeground(UIManager.getColor("Tree.selectionForeground"));
    }

    if (selected) {
      jl.setBackground(UIManager.getColor("Tree.selectionBackground"));
    } else {
      jl.setBackground(UIManager.getColor("Tree.textBackground"));
    }

    return this;
  }
  private void createButtons() {
    myCloseButton =
        createButton("Close", UIManager.getIcon("InternalFrame.closeIcon"), myCloseAction);

    if (getWindowDecorationStyle() == JRootPane.FRAME) {
      myMaximizeIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
      myMinimizeIcon = UIManager.getIcon("InternalFrame.minimizeIcon");

      myIconifyButton =
          createButton("Iconify", UIManager.getIcon("InternalFrame.iconifyIcon"), myIconifyAction);
      myToggleButton = createButton("Maximize", myMaximizeIcon, myRestoreAction);
    }
  }
  // {{{createNorthPanelAll() method
  public JPanel createNorthPanelAll() {
    JPanel northPanel = new JPanel(new BorderLayout());

    infoIcon = new JLabel();
    infoIcon.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
    northPanel.add(BorderLayout.WEST, infoIcon);

    int filesCounter = 0;
    int directoriesCounter = 0;
    for (VFSFile selectedFile : selectedFiles) {
      if (selectedFile.getType() == VFSFile.DIRECTORY) directoriesCounter++;
      else if (selectedFile.getType() == VFSFile.FILE) filesCounter++;
    }
    JPanel nameField = new JPanel();
    nameField.add(
        new JLabel(
            jEdit.getProperty("fileprop.selectedFiles")
                + ": "
                + filesCounter
                + ", "
                + jEdit.getProperty("fileprop.selectedDirectories")
                + ": "
                + directoriesCounter));

    northPanel.add(BorderLayout.CENTER, nameField);
    northPanel.add(BorderLayout.SOUTH, new JPanel());

    return northPanel;
  } // }}}
  // {{{ createNorthPanel() method
  public JPanel createNorthPanel() {
    JPanel northPanel = new JPanel(new BorderLayout());

    infoIcon = new JLabel();
    infoIcon.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
    northPanel.add(BorderLayout.WEST, infoIcon);

    JPanel nameField = new JPanel();
    nameField.add(new JLabel(jEdit.getProperty("fileprop.name") + ": "));
    String filename;
    if (local instanceof FavoritesVFS.Favorite) {
      FavoritesVFS.Favorite favorite = (FavoritesVFS.Favorite) local;
      filename = favorite.getLabel();
    } else {
      filename = local.getName();
    }
    nameTextField = new JTextField(filename, 20);
    if ((local.getVFS().getCapabilities() & VFS.RENAME_CAP) == 0) {
      // If the VFS cannot rename, the nameTextField is non editable
      nameTextField.setEditable(false);
    }
    nameField.add(nameTextField);
    northPanel.add(BorderLayout.CENTER, nameField);
    northPanel.add(BorderLayout.SOUTH, new JPanel());

    return northPanel;
  } // }}}
class IndeterminateIcon implements Icon {
  private final Color FOREGROUND =
      new Color(50, 20, 255, 200); // TEST: UIManager.getColor("CheckBox.foreground");
  private final Icon icon = UIManager.getIcon("CheckBox.icon");
  private static final int a = 4;
  private static final int b = 2;

  @Override
  public void paintIcon(Component c, Graphics g, int x, int y) {
    icon.paintIcon(c, g, x, y);
    int w = getIconWidth();
    int h = getIconHeight();
    Graphics2D g2 = (Graphics2D) g;
    g2.setPaint(FOREGROUND);
    g2.translate(x, y);
    g2.fillRect(a, (h - b) / 2, w - a - a, b);
    g2.translate(-x, -y);
  }

  @Override
  public int getIconWidth() {
    return icon.getIconWidth();
  }

  @Override
  public int getIconHeight() {
    return icon.getIconHeight();
  }
}
 /**
  * Icon for a file, directory, or folder as it would be displayed in a system file browser.
  *
  * @param f a <code>File</code> object
  * @return an icon as it would be displayed by a native file chooser, null if not available
  * @see JFileChooser#getIcon
  */
 public Icon getSystemIcon(File f) {
   if (f != null) {
     return UIManager.getIcon(f.isDirectory() ? "FileView.directoryIcon" : "FileView.fileIcon");
   } else {
     return null;
   }
 }
Beispiel #11
0
  /** ******************************************************************* */
  protected HelpMenu() {
    super("Help");

    setMnemonic('H');

    Icon icon;
    JMenuItem menuItem;

    //
    // Online Help menu item
    //
    icon = UIManager.getIcon("help");
    menuItem = new JMenuItem("Online Help", icon);
    menuItem.addActionListener(new HelpActionListener());
    menuItem.setMnemonic('H');
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_MASK));
    add(menuItem);

    //
    // Separator
    //
    add(new JSeparator());

    //
    // About menu item
    //
    menuItem = new JMenuItem("About...");
    menuItem.addActionListener(new AboutActionListener());
    menuItem.setMnemonic('A');
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK));
    add(menuItem);
  }
Beispiel #12
0
 /**
  * Convience method for only replacing icons if they have not been customized by the user. Returns
  * the icon from the defaults table belonging to <code>resKey</code>, if {@link
  * #shouldReplaceResource(Object)} with the <code>icon</code> as a parameter returns <code>true
  * </code>. Otherwise returns <code>icon</code>.
  *
  * @param icon the current icon
  * @param resKey the resource key identifying the default icon
  * @return the new icon
  */
 protected Icon getNewIcon(Icon icon, String resKey) {
   Icon uiIcon = UIManager.getIcon(resKey);
   if (shouldReplaceResource(icon)) {
     return uiIcon;
   }
   return icon;
 }
Beispiel #13
0
 // ********************************
 //          Defaults
 // ********************************
 public void installDefaults(AbstractButton b) {
   super.installDefaults(b);
   if (!defaults_initialized) {
     icon = UIManager.getIcon(getPropertyPrefix() + "icon");
     defaults_initialized = true;
   }
 }
 public static Map<String, Object> mensajeError(Exception e, String nombreClase) {
   JLabel jlMensaje =
       new JLabel(
           "<html>Lo sentimos, hemos detectado un error interno.<br/><br/>"
               + "<font size=5>¿Desea informar este problema?</font><br/><br/>"
               + "Se ha creado un informe de error que puede enviar para mejorar ShrimSoft.<br/>"
               + "Adicionalmente puede detallarnos sobre que provocó este error.</html>");
   JTextArea jtaMensaje = new JTextArea();
   jtaMensaje.setRows(6);
   jtaMensaje.setColumns(40);
   Object[] comp = {jlMensaje, jtaMensaje};
   Object[] botones = {"Enviar informe de error", "Cancelar"};
   int i =
       JOptionPane.showOptionDialog(
           null,
           comp,
           "ShrimSoft",
           JOptionPane.YES_NO_OPTION,
           JOptionPane.ERROR_MESSAGE,
           UIManager.getIcon("OptionPane.errorIcon"),
           botones,
           null);
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("opcion", i);
   map.put("mensaje", jtaMensaje.getText());
   return map;
 }
Beispiel #15
0
  private static Icon getOpenIcon() {
    if (openIcon == null) {
      openIcon = UIManager.getIcon("Tree.openIcon");
    }

    return openIcon;
  }
Beispiel #16
0
 protected Icon getApplicationIcon(String filename) {
   if (isApplicationValid(filename)) {
     return fs.getSystemIcon(getApplication(filename));
   } else {
     return UIManager.getIcon("FileView.fileIcon");
   }
 }
Beispiel #17
0
 /**
  * Returns default folder icon as {@link java.awt.Image}. Never returns <code>null</code>.
  *
  * @param opened whether closed or opened icon should be returned.
  */
 public static Image getTreeFolderIcon(boolean opened) {
   Image base =
       (Image)
           UIManager.get(opened ? OPENED_ICON_KEY_UIMANAGER_NB : ICON_KEY_UIMANAGER_NB); // #70263;
   if (base == null) {
     Icon baseIcon =
         UIManager.getIcon(opened ? OPENED_ICON_KEY_UIMANAGER : ICON_KEY_UIMANAGER); // #70263
     if (baseIcon != null) {
       base = ImageUtilities.icon2Image(baseIcon);
     } else {
       try {
         // fallback to our owns
         return opened
             ? DataObject.find(FileUtil.getConfigRoot())
                 .getNodeDelegate()
                 .getOpenedIcon(BeanInfo.ICON_COLOR_16x16)
             : DataObject.find(FileUtil.getConfigRoot())
                 .getNodeDelegate()
                 .getIcon(BeanInfo.ICON_COLOR_16x16);
       } catch (DataObjectNotFoundException ex) {
         Exceptions.printStackTrace(ex);
       }
     }
   }
   assert base != null;
   return base;
 }
 private static Icon createPartiallyIncludedIcon() {
   Icon icon = UIManager.getIcon("CheckBox.icon");
   if (icon == null || icon.getIconWidth() == 0 || icon.getIconHeight() == 0) {
     icon = MetalIconFactory.getCheckBoxIcon();
   }
   return createDisabledIcon(configureCheckBox(new JCheckBox()), icon);
 }
Beispiel #19
0
  private void setupUI() {
    // Set up UI
    this.setLocation(455, 45 + (Task.numberOfTasks * 52));
    this.getContentPane().setBackground(Color.DARK_GRAY);
    Dimension d = new Dimension(100, 100);
    this.setPreferredSize(d);
    this.pack();

    // Set up content
    pnlTimer.setLayout(flTimer);
    pnlTimer.setBackground(Color.DARK_GRAY);
    this.add(pnlTimer);

    // Set up components
    lblTimeRemaining = new JLabel(task.getTaskLengthAsString() + ":00");
    lblTimeRemaining.setFont(new Font("sans-serif", Font.PLAIN, 25));
    lblTimeRemaining.setForeground(Color.WHITE);
    btnPause = new JButton();
    btnStop = new JButton();
    btnPause.setIcon(UIManager.getIcon("FileView.floppyDriveIcon"));
    btnStop.setIcon(UIManager.getIcon("FileView.hardDriveIcon"));

    // Add components to layout
    pnlTimer.add(lblTimeRemaining);
    pnlTimer.add(btnPause);
    pnlTimer.add(btnStop);

    // Set up timer that repeats every second
    t1 =
        new Timer(
            1000,
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                // Update UI
                lblTimeRemaining.setText(
                    task.getMinutesRemaining() + ":" + task.getSecondsRemaining());

                task.decrementTimer();

                // Repeat timer until completed
                if (!lblTimeRemaining.getText().equals("00:00") && continueLooping) t1.restart();
                else t1.stop();
              }
            });
    t1.start();
  }
Beispiel #20
0
 // Méthode personnelle pour montrer les erreurs graphiquement
 private void messageErreur(String message) {
   JOptionPane.showMessageDialog(
       null,
       message,
       "ERREUR",
       JOptionPane.ERROR_MESSAGE,
       UIManager.getIcon("OptionPane.errorIcon"));
 }
Beispiel #21
0
 public BasicSearchNavigatorUI(JHelpSearchNavigator b) {
   ImageIcon icon = getImageIcon(b.getNavigatorView());
   if (icon != null) {
     setIcon(icon);
   } else {
     setIcon(UIManager.getIcon("SearchNav.icon"));
   }
 }
  public ErrorListDialog(
      Frame frame, String title, String caption, Vector messages, boolean showPluginMgrButton) {
    super(frame, title, true);

    JPanel content = new JPanel(new BorderLayout(12, 12));
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    Box iconBox = new Box(BoxLayout.Y_AXIS);
    iconBox.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon")));
    iconBox.add(Box.createGlue());
    content.add(BorderLayout.WEST, iconBox);

    JPanel centerPanel = new JPanel(new BorderLayout());

    JLabel label = new JLabel(caption);
    label.setBorder(new EmptyBorder(0, 0, 6, 0));
    centerPanel.add(BorderLayout.NORTH, label);

    JList errors = new JList(messages);
    errors.setCellRenderer(new ErrorListCellRenderer());
    errors.setVisibleRowCount(Math.min(messages.size(), 4));

    JScrollPane scrollPane =
        new JScrollPane(
            errors, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    Dimension size = scrollPane.getPreferredSize();
    size.width = Math.min(size.width, 400);
    scrollPane.setPreferredSize(size);

    centerPanel.add(BorderLayout.CENTER, scrollPane);

    content.add(BorderLayout.CENTER, centerPanel);

    Box buttons = new Box(BoxLayout.X_AXIS);
    buttons.add(Box.createGlue());

    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(new ActionHandler());

    if (showPluginMgrButton) {
      pluginMgr = new JButton(jEdit.getProperty("error-list.plugin-manager"));
      pluginMgr.addActionListener(new ActionHandler());
      buttons.add(pluginMgr);
      buttons.add(Box.createHorizontalStrut(6));
    }

    buttons.add(ok);

    buttons.add(Box.createGlue());
    content.add(BorderLayout.SOUTH, buttons);

    getRootPane().setDefaultButton(ok);

    pack();
    setLocationRelativeTo(frame);
    show();
  }
Beispiel #23
0
 private JComponent createCloseButton() {
   ToolBarButton toolBarButton = new ToolBarButton();
   Action closeAction = getToggleAction();
   // TODO: ImageIcon verwenden
   Icon icon = UIManager.getIcon("Tree.expandedIcon");
   closeAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, icon);
   closeAction.putValue(Action.NAME, null);
   toolBarButton.setAction(closeAction);
   return toolBarButton;
 }
 protected void installDefaults() {
   super.installDefaults();
   setFont(UIManager.getFont("InternalFrame.titleFont"));
   paletteTitleHeight = UIManager.getInt("InternalFrame.paletteTitleHeight");
   paletteCloseIcon = UIManager.getIcon("InternalFrame.paletteCloseIcon");
   wasClosable = frame.isClosable();
   selectedForegroundKey = selectedBackgroundKey = null;
   if (MetalLookAndFeel.usingOcean()) {
     setOpaque(true);
   }
 }
 /**
  * Constructs and initializes this object
  *
  * @param viewerPanel the <code>JImageViewerPanel</code> this action is linked to
  * @param imageType
  */
 public ImageViewerPanelSaveAction(JImageViewerPanel viewerPanel, int imageType) {
   super(messagesBundle.getString("ImageViewerPanelSaveAction.Save_1")); // $NON-NLS-1$
   assert viewerPanel != null;
   this.imageType = imageType;
   this.viewerPanel = viewerPanel;
   putValue(
       SHORT_DESCRIPTION,
       messagesBundle.getString("ImageViewerPanelSaveAction.Save_image_to_file_2"));
   //$NON-NLS-1$
   putValue(SMALL_ICON, UIManager.getIcon("FileView.floppyDriveIcon")); // $NON-NLS-1$
 }
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (UIUtil.isUnderAquaLookAndFeel()) {
      return;
    }

    switch (getState()) {
      case DONT_CARE:
        Icon icon = getIcon();
        if (icon == null) {
          icon = UIManager.getIcon("CheckBox.icon");
        }
        if (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
          icon = EmptyIcon.create(20, 18);
        }
        if (icon != null) {
          final Insets i = getInsets();
          final Rectangle r = getBounds();
          final Rectangle r1 = new Rectangle();
          r1.x = i.left;
          r1.y = i.top;
          r1.width = r.width - (i.right + r1.x);
          r1.height = r.height - (i.bottom + r1.y);

          final Rectangle r2 = new Rectangle();
          final Rectangle r3 = new Rectangle();
          SwingUtilities.layoutCompoundLabel(
              this,
              getFontMetrics(getFont()),
              getText(),
              icon,
              getVerticalAlignment(),
              getHorizontalAlignment(),
              getVerticalTextPosition(),
              getHorizontalTextPosition(),
              r1,
              r2,
              r3,
              getText() == null ? 0 : getIconTextGap());

          // selected table cell: do not paint white on white
          g.setColor(UIUtil.getTreeForeground());
          int height = r2.height / 10;
          int width = r2.width / 3;
          g.fillRect(
              r2.x + r2.width / 2 - width / 2, r2.y + r2.height / 2 - height / 2, width, height);
        }
        break;
      default:
        break;
    }
  }
  public void showErrorDialog(Throwable th) {
    th.printStackTrace();

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    th.printStackTrace(new PrintStream(bos));

    JPanel panel = new JPanel(new BorderLayout());
    JLabel label =
        new JLabel(
            "Unexpected error occurred: '" + th.getMessage() + "' with stack trace:",
            UIManager.getIcon("OptionPane.errorIcon"),
            SwingConstants.LEFT);
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.add(label, BorderLayout.NORTH);
    final JTextArea text = new JTextArea(new String(bos.toByteArray()));
    text.setEditable(false);
    text.setRows(10);
    text.setColumns(50);
    panel.add(new JScrollPane(text), BorderLayout.CENTER);

    final JDialog dialog = new JDialog(getOwner(), "SQLJet Error", true);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JButton button = new JButton("Close");
    button.setMnemonic('C');
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
            dialog.dispose();
          }
        });
    JButton copyButton = new JButton("Copy");
    copyButton.setMnemonic('o');
    copyButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            StringSelection trace = new StringSelection(text.getText());
            Clipboard cp = Toolkit.getDefaultToolkit().getSystemClipboard();
            cp.setContents(trace, trace);
          }
        });
    buttonPanel.add(copyButton);
    buttonPanel.add(button);
    dialog.getRootPane().setDefaultButton(button);
    panel.add(buttonPanel, BorderLayout.SOUTH);
    dialog.setContentPane(panel);
    dialog.pack();
    dialog.setLocationRelativeTo(getOwner());
    dialog.setVisible(true);
  }
Beispiel #28
0
 private static int getTreeBaseline(JTree tree, int height) {
   int rowHeight = tree.getRowHeight();
   if (TREE_LABEL == null) {
     TREE_LABEL = new JLabel("X");
     TREE_LABEL.setIcon(UIManager.getIcon("Tree.closedIcon"));
   }
   JLabel label = TREE_LABEL;
   label.setFont(tree.getFont());
   if (rowHeight <= 0) {
     rowHeight = label.getPreferredSize().height;
   }
   return getLabelBaseline(label, rowHeight) + tree.getInsets().top;
 }
 private void grandInit() {
   initComponents();
   icon.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
   DockingUI.displayCentered(this);
   StaticUIUtils.setEscapeAction(
       this,
       new AbstractAction() {
         @Override
         public void actionPerformed(ActionEvent e) {
           cancelButtonActionPerformed(null);
         }
       });
 }
  static void showCollapsiblePane() {
    JXCollapsiblePane cp = new JXCollapsiblePane();

    // JXCollapsiblePane can be used like any other container
    cp.setLayout(new BorderLayout());

    // the Controls panel with a textfield to filter the tree
    JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 0));
    controls.add(new JLabel("Search:"));
    controls.add(new JTextField(10));
    controls.add(new JButton("Refresh"));
    controls.setBorder(new TitledBorder("Filters"));
    cp.add("Center", controls);

    JXFrame frame = new JXFrame();
    frame.setLayout(new BorderLayout());

    // Put the "Controls" first
    frame.add("North", cp);

    // Then the tree - we assume the Controls would somehow filter the tree
    JScrollPane scroll = new JScrollPane(new JTree());
    frame.add("Center", scroll);

    // Show/hide the "Controls"
    JButton toggle = new JButton(cp.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION));
    toggle.setText("Show/Hide Search Panel");
    frame.add("South", toggle);
    // get the built-in toggle action
    Action toggleAction = cp.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION);

    // use the collapse/expand icons from the JTree UI
    toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager.getIcon("Tree.expandedIcon"));
    toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager.getIcon("Tree.collapsedIcon"));

    frame.pack();
    frame.setVisible(true);
  }