@Override public void addCustomEntriesToTable(UIDefaults table) { super.addCustomEntriesToTable(table); final int internalFrameIconSize = 22; table.put("InternalFrame.closeIcon", MetalIconFactory. getInternalFrameCloseIcon(internalFrameIconSize)); table.put("InternalFrame.maximizeIcon", MetalIconFactory. getInternalFrameMaximizeIcon(internalFrameIconSize)); table.put("InternalFrame.iconifyIcon", MetalIconFactory. getInternalFrameMinimizeIcon(internalFrameIconSize)); table.put("InternalFrame.minimizeIcon", MetalIconFactory. getInternalFrameAltMaximizeIcon(internalFrameIconSize)); table.put("ScrollBar.width", 21); }
public JButton customizeButton() { final CustomJButton open = new CustomJButton("+", MetalIconFactory.getTreeLeafIcon()); open.setHorizontalTextPosition(JButton.CENTER); open.setForeground(Color.lightGray); open.setToolTipText(Messages.getString("RendererPanel.5")); open.setFocusPainted(false); open.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { DeviceConfiguration d = (DeviceConfiguration) renderer; File f = chooseConf(d.getDeviceDir(), d.getDefaultFilename(d)); if (f != null) { File file = DeviceConfiguration.createDeviceFile(d, f.getName(), true); buildEditBar(true); try { java.awt.Desktop.getDesktop().open(file); } catch (IOException ioe) { LOGGER.debug("Failed to open default desktop application: " + ioe); } } } }); return open; }
public JButton referenceButton() { final File ref = ((DeviceConfiguration) renderer).getConfiguration(DeviceConfiguration.RENDERER).getFile(); final CustomJButton open = new CustomJButton(MetalIconFactory.getTreeLeafIcon()); boolean exists = ref != null && ref.exists(); open.setToolTipText(exists ? (Messages.getString("RendererPanel.3") + ": " + ref) : Messages.getString("RendererPanel.4")); open.setFocusPainted(false); open.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { try { java.awt.Desktop.getDesktop().open(ref); } catch (IOException ioe) { LOGGER.debug("Failed to open default desktop application: " + ioe); } } }); if (!exists) { open.setText("!"); open.setHorizontalTextPosition(JButton.CENTER); open.setForeground(Color.lightGray); open.setEnabled(false); } return open; }
public void testReplaceSelection_AtTheBeginningOfParagraph() { StyledDocument doc = textPane.getStyledDocument(); try { attrs = new SimpleAttributeSet(); StyleConstants.setUnderline(attrs, true); doc.insertString(0, "Hello word!", attrs); textPane.setCaretPosition(4); textPane.insertIcon(MetalIconFactory.getTreeFolderIcon()); textPane.setCaretPosition(4); textPane.replaceSelection("\n"); textPane.setCaretPosition(5); textPane.replaceSelection("a"); textPane.setCaretPosition(6); textPane.replaceSelection("b"); assertNull(StyleConstants.getIcon(doc.getCharacterElement(5).getAttributes())); assertNull(StyleConstants.getIcon(doc.getCharacterElement(6).getAttributes())); } catch (BadLocationException e) { } }
@Override public void restored() { if (detectOldJava()) { final String title = NbBundle.getMessage(Installer.class, "wlc-nbeditorconfig-version-error-title"); final String message = NbBundle.getMessage(Installer.class, "wlc-nbeditorconfig-version-error-message"); final int messageType = NotifyDescriptor.ERROR_MESSAGE; ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, messageType)); } }; NotificationDisplayer.getDefault().notify(title, new MetalIconFactory.FileIcon16(), message, actionListener); } }
public void dragGestureRecognized(DragGestureEvent e) { Object o = view.locationToObject(e.getComponent(), e.getDragOrigin()); if(o != null) { if(e.getDragSource().isDragImageSupported()) { if(FILE == null) { FILE = Swing.iconToImage(MetalIconFactory.getTreeLeafIcon()); FOLDER = Swing.iconToImage(MetalIconFactory.getTreeFolderIcon()); } BufferedImage image = model.isLeaf(o) ? FILE : FOLDER; e.startDrag(DragSource.DefaultMoveDrop, image, new Point(image.getWidth() / 2, image.getHeight() / 2), new StringSelection(o.toString()), this); } else e.startDrag(DragSource.DefaultMoveDrop, // cursor new StringSelection(o.toString()), // transferable this); // drag source listener } }
private void refreshTree() { tree = new JTree(simDir); if (!topLevel /*&& learnSpecs == null*/) { tree.addMouseListener(this); } tree.putClientProperty("JTree.icons", makeIcons()); tree.setCellRenderer(new IconNodeRenderer()); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); renderer.setLeafIcon(MetalIconFactory.getTreeLeafIcon()); renderer.setClosedIcon(MetalIconFactory.getTreeFolderIcon()); renderer.setOpenIcon(MetalIconFactory.getTreeFolderIcon()); }
private static Hashtable<String, Icon> makeIcons() { Hashtable<String, Icon> icons = new Hashtable<String, Icon>(); icons.put("floppyDrive", MetalIconFactory.getTreeFloppyDriveIcon()); icons.put("hardDrive", MetalIconFactory.getTreeHardDriveIcon()); icons.put("computer", MetalIconFactory.getTreeComputerIcon()); icons.put("c", TextIcons.getIcon("c")); icons.put("java", TextIcons.getIcon("java")); icons.put("html", TextIcons.getIcon("html")); return icons; }
/** * This panel contains combo boxes with a custom renderer. * * @return A panel. */ private JPanel createPanel6() { JPanel panel = new JPanel(new BorderLayout()); this.comboState6 = new JCheckBox("Enabled", true); this.comboState6.setActionCommand("COMBO_STATE6"); this.comboState6.addActionListener(this); panel.add(this.comboState6, BorderLayout.EAST); JPanel controlPanel = new JPanel(); controlPanel.setBorder(BorderFactory.createTitledBorder("Custom Renderer: ")); this.combo11 = new JComboBox(new Object[] { MetalIconFactory.getFileChooserHomeFolderIcon(), MetalIconFactory.getFileChooserNewFolderIcon()}); this.combo11.setPreferredSize(new Dimension(100, 30)); this.combo11.setRenderer(new CustomCellRenderer()); this.combo12 = new JComboBox(new Object[] { MetalIconFactory.getFileChooserHomeFolderIcon(), MetalIconFactory.getFileChooserNewFolderIcon()}); this.combo12.setPreferredSize(new Dimension(100, 30)); this.combo12.setRenderer(new CustomCellRenderer()); this.combo12.setEditable(true); controlPanel.add(combo11); controlPanel.add(combo12); panel.add(controlPanel); return panel; }
private JPanel createButtonPanel() { JPanel panel = new JPanel(new BorderLayout()); this.buttonState = new JCheckBox("Enabled", true); this.buttonState.setActionCommand("BUTTON_STATE"); this.buttonState.addActionListener(this); panel.add(this.buttonState, BorderLayout.EAST); JPanel buttonPanel = new JPanel(); buttonPanel.setBorder(BorderFactory.createTitledBorder("JButton")); this.button1 = new JButton("Button 1"); this.button2 = new JButton("Button 2"); this.button2.setIcon(MetalIconFactory.getInternalFrameDefaultMenuIcon()); this.button3 = new JButton("Button 3"); this.button3.setIcon(MetalIconFactory.getFileChooserHomeFolderIcon()); this.button3.setHorizontalTextPosition(SwingConstants.CENTER); this.button3.setVerticalTextPosition(SwingConstants.BOTTOM); this.button4 = new JButton("Button 4"); this.button4.setIcon(MetalIconFactory.getFileChooserUpFolderIcon()); this.button4.setText(null); buttonPanel.add(button1); buttonPanel.add(button2); buttonPanel.add(button3); buttonPanel.add(button4); panel.add(buttonPanel); return panel; }
/** * Installs the icons for this UI delegate. * * @param fc the file chooser (ignored). */ protected void installIcons(JFileChooser fc) { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); computerIcon = MetalIconFactory.getTreeComputerIcon(); detailsViewIcon = defaults.getIcon("FileChooser.detailsViewIcon"); directoryIcon = new MetalIconFactory.TreeFolderIcon(); fileIcon = new MetalIconFactory.TreeLeafIcon(); floppyDriveIcon = MetalIconFactory.getTreeFloppyDriveIcon(); hardDriveIcon = MetalIconFactory.getTreeHardDriveIcon(); homeFolderIcon = defaults.getIcon("FileChooser.homeFolderIcon"); listViewIcon = defaults.getIcon("FileChooser.listViewIcon"); newFolderIcon = defaults.getIcon("FileChooser.newFolderIcon"); upFolderIcon = defaults.getIcon("FileChooser.upFolderIcon"); }
public void testReplaceSelection_WithSelection() { textPane.setCaretPosition(4); textPane.insertIcon(MetalIconFactory.getTreeFolderIcon()); textPane.select(4, 6); textPane.replaceSelection("TEXT"); assertNull(StyleConstants.getIcon(textPane.getStyledDocument().getCharacterElement(4) .getAttributes())); }
public void testInputAttributes() { JEditorPane pane = new JEditorPane() { private static final long serialVersionUID = 1L; @Override protected EditorKit createDefaultEditorKit() { return new StyledEditorKit(); } }; pane.setEditorKit(new StyledEditorKit()); StyledDocument doc = (StyledDocument) pane.getDocument(); StyledEditorKit kit = (StyledEditorKit) pane.getEditorKit(); try { MutableAttributeSet attrs = new SimpleAttributeSet(); StyleConstants.setUnderline(attrs, true); doc.insertString(0, "Hello word!", attrs); pane.setCaretPosition(4); attrs = new SimpleAttributeSet(); StyleConstants.setIcon(attrs, MetalIconFactory.getTreeFolderIcon()); doc.insertString(4, " ", attrs); pane.setCaretPosition(4); doc.insertString(4, "\n", kit.getInputAttributes()); assertFalse(StyleConstants.isUnderline(kit.getInputAttributes())); pane.setCaretPosition(5); assertFalse(StyleConstants.isUnderline(kit.getInputAttributes())); } catch (BadLocationException e) { } }
@Override protected void setUp() throws Exception { super.setUp(); textPane = new JTextPane(); document = textPane.getStyledDocument(); icon = MetalIconFactory.getCheckBoxMenuItemIcon(); document.insertString(0, "Hello\n word!!!", new SimpleAttributeSet()); textPane.setCaretPosition(3); textPane.insertIcon(icon); iconElement = document.getDefaultRootElement().getElement(0).getElement(1); view = new IconView(iconElement); }
public void testGetPreferredSpan() { if (isHarmony()) { assertEquals(icon.getIconWidth() + 2, view.getPreferredSpan(View.X_AXIS), 1); } else { assertEquals(icon.getIconWidth(), view.getPreferredSpan(View.X_AXIS), 1); } assertEquals(icon.getIconHeight(), view.getPreferredSpan(View.Y_AXIS), 1); testExceptionalCase(new IllegalArgumentCase() { @Override public void exceptionalAction() throws Exception { view.getPreferredSpan(2); } }); testExceptionalCase(new IllegalArgumentCase() { @Override public void exceptionalAction() throws Exception { view.getPreferredSpan(-1); } }); MutableAttributeSet attrs = new SimpleAttributeSet(); icon = MetalIconFactory.getRadioButtonIcon(); StyleConstants.setIcon(attrs, icon); document.setCharacterAttributes(3, 1, attrs, true); view = new IconView(iconElement); if (isHarmony()) { assertEquals(icon.getIconWidth() + 2, view.getPreferredSpan(View.X_AXIS), 0.1); } else { assertEquals(icon.getIconWidth(), view.getPreferredSpan(View.X_AXIS), 0.1); } assertEquals(icon.getIconHeight(), view.getPreferredSpan(View.Y_AXIS), 0.1); }