/** * {@inheritDoc} */ @Override protected void uninstallDefaults() { table.setDefaultRenderer(Date.class, dateRenderer); table.setDefaultRenderer(Number.class, numberRenderer); table.setDefaultRenderer(Double.class, doubleRender); table.setDefaultRenderer(Float.class, floatRenderer); table.setDefaultRenderer(Icon.class, iconRenderer); table.setDefaultRenderer(ImageIcon.class, imageIconRenderer); table.setDefaultRenderer(Boolean.class, booleanRenderer); table.setDefaultRenderer(Object.class, objectRenderer); if (table.getTransferHandler() instanceof UIResource) { table.setTransferHandler(null); } SynthContext context = getContext(table, ENABLED); style.uninstallDefaults(context); context.dispose(); style = null; }
private JPanel makeInfoPanel(String message, Icon icon) { JLabel infoIcon = new JLabel(icon); infoIcon.setVerticalAlignment(SwingConstants.TOP); JPanel infoPanel = new JPanel(new BorderLayout(20, 0)); infoPanel.setBorder(BorderFactory.createEmptyBorder(12, 16, 16, 4)); infoPanel.add(infoIcon, BorderLayout.WEST); int width; if (centerComponent != null) { width = (int) centerComponent.getPreferredSize().getWidth() - 88; // icon plus padding if (width < 420) { width = 420; } } else { width = 420; } infoTextLabel = new FixedWidthEditorPane(width, message); // set the background as for infoPanel such that infoTextLabel looks like a JLabel infoTextLabel.setBackground(infoPanel.getBackground()); infoPanel.add(infoTextLabel, BorderLayout.CENTER); return infoPanel; }
private static Icon getIcon(Prop prop) { String cacheKey = Game.getEnvironment().getMap().getName() + "-" + prop.getName() + "-" + prop.getMapId() + "-tree"; BufferedImage propImag; if (ImageCache.IMAGES.containsKey(cacheKey)) { propImag = ImageCache.IMAGES.get(cacheKey); } else { final String name = "prop-" + prop.getSpritesheetName().toLowerCase() + "-" + PropState.INTACT.toString().toLowerCase(); final String fallbackName = "prop-" + prop.getSpritesheetName().toLowerCase(); Spritesheet sprite = Spritesheet.find(name); if (sprite == null) { sprite = Spritesheet.find(fallbackName); } if (sprite == null) { return null; } propImag = ImageProcessing.scaleImage(sprite.getSprite(0), 16, 16, true); ImageCache.IMAGES.put(cacheKey, propImag); } return new ImageIcon(propImag); }
private Icon getIcon(String plotterName, boolean selected) { // check to decide which icon size should be loaded if (!isSmallIconsUsed()) { if (selected) { return SwingTools.createImage("icons/chartPreview/" + ICON_SIZE + "/" + plotterName.replace(' ', '_') + ".png"); } else { return SwingTools.createImage("icons/chartPreview/" + ICON_SIZE + "/" + plotterName.replace(' ', '_') + "-grey.png"); } } else { if (selected) { return SwingTools.createImage("icons/chartPreview/" + SMALL_ICON_SIZE + "/" + plotterName.replace(' ', '_') + ".png"); } else { return SwingTools.createImage("icons/chartPreview/" + SMALL_ICON_SIZE + "/" + plotterName.replace(' ', '_') + "-grey.png"); } } }
private static Icon createMenuIcon(Icon icon, Component decorator) { int h = menuIconSize(); int w = UIUtils.isAquaLookAndFeel() ? h + 4 : h; BufferedImage i = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics g = i.getGraphics(); if (decorator != null) { decorator.setSize(w, h); decorator.paint(g); } icon.paintIcon(null, g, (w - icon.getIconWidth()) / 2, (h - icon.getIconHeight()) / 2); g.dispose(); return new ImageIcon(i); }
public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); if (PREFERRED_HEIGHT == -1) { GenericToolbar tb = new GenericToolbar(); tb.setBorder(getBorder()); tb.setBorderPainted(isBorderPainted()); tb.setRollover(isRollover()); tb.setFloatable(isFloatable()); Icon icon = Icons.getIcon(GeneralIcons.SAVE); tb.add(new JButton("Button", icon)); // NOI18N tb.add(new JToggleButton("Button", icon)); // NOI18N tb.add(new JTextField("Text")); // NOI18N JComboBox c = new JComboBox(); c.setEditor(new BasicComboBoxEditor()); c.setRenderer(new BasicComboBoxRenderer()); tb.add(c); tb.addSeparator(); PREFERRED_HEIGHT = tb.getSuperPreferredSize().height; } dim.height = getParent() instanceof JToolBar ? 1 : Math.max(dim.height, PREFERRED_HEIGHT); return dim; }
@Override public void paintIcon(ComponentDrawContext c, int x, int y) { FactoryDescription desc = description; if (desc != null && !desc.isFactoryLoaded()) { Icon icon = desc.getIcon(); if (icon != null) { icon.paintIcon(c.getDestination(), c.getGraphics(), x + 2, y + 2); return; } } ComponentFactory source = getFactory(); if (source != null) { AttributeSet base = getBaseAttributes(); source.paintIcon(c, x, y, base); } }
public @Override Icon getIcon(File _f) { File f = FileUtil.normalizeFile(_f); Icon original = fsv.getSystemIcon(f); if (original == null) { // L&F (e.g. GTK) did not specify any icon. original = EMPTY; } if ( isPlatformDir( f ) ) { if ( original.equals( lastOriginal ) ) { return lastMerged; } lastOriginal = original; lastMerged = new MergedIcon(original, BADGE, -1, -1); return lastMerged; } else { return original; } }
/** * @return map of maven artifact mapped to project icon */ private Map<Artifact, Icon> getIconsForOpenProjects() { Map<Artifact, Icon> result = new HashMap<Artifact, Icon>(); //NOTE: surely not the best way to get the project icon Project[] openProjects = OpenProjects.getDefault().getOpenProjects(); for (Project project : openProjects) { NbMavenProject mavenProject = project.getLookup().lookup(NbMavenProject.class); if (null != mavenProject) { Artifact artifact = mavenProject.getMavenProject().getArtifact(); //get icon from opened project Icon icon = ProjectUtils.getInformation(project).getIcon(); if (null != icon) { result.put(artifact, icon); } } } return result; }
private static Icon getCloseTabImage() { if( null == closeTabImage ) { String path = UIManager.getString("nb.close.tab.icon.enabled.name" ); //NOI18N if( null != path ) { closeTabImage = ImageUtilities.loadImageIcon(path, true); // NOI18N } } if( null == closeTabImage ) { if( isWindows8LaF() || isWindows10LaF() ) { closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/win8_bigclose_enabled.png", true); // NOI18N } else if( isWindowsVistaLaF() ) { closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/vista_close_enabled.png", true); // NOI18N } else if( isWindowsXPLaF() ) { closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/xp_close_enabled.png", true); // NOI18N } else if( isWindowsLaF() ) { closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/win_close_enabled.png", true); // NOI18N } else if( isAquaLaF() ) { closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/mac_close_enabled.png", true); // NOI18N } else if( isGTKLaF() ) { closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/gtk_close_enabled.png", true); // NOI18N } else { closeTabImage = ImageUtilities.loadImageIcon("org/openide/awt/resources/metal_close_enabled.png", true); // NOI18N } } return closeTabImage; }
/** * Returns an icon for the given {@link ModuleElement.DirectiveKind}. * @param kind the {@link ModuleElement.DirectiveKind} to return an icon for. * @return the icon * @since 1.45 */ public static Icon getModuleDirectiveIcon(@NonNull final ModuleElement.DirectiveKind kind) { Parameters.notNull("kind", kind); //NOI18N switch (kind) { case EXPORTS: return ImageUtilities.loadImageIcon(EXPORTS_ICON, true); case REQUIRES: return ImageUtilities.loadImageIcon(REQUIRES_ICON, true); case USES: return ImageUtilities.loadImageIcon(USES_ICON, true); case PROVIDES: return ImageUtilities.loadImageIcon(PROVIDES_ICON, true); case OPENS: return ImageUtilities.loadImageIcon(OPENS_ICON, true); default: throw new IllegalArgumentException(kind.toString()); } }
/** * Creates a tabpage title component with close button and registers it to * hidden tabs * * @return the new tab */ private JPanel createTab(String title, Icon icon, final Component component) { JPanel tab = new JPanel(new BorderLayout(0, 0)); tab.setOpaque(false); JLabel lbl = new JLabel(title, icon, SwingConstants.LEFT); tab.add(lbl, BorderLayout.WEST); return tab; }
/** * Creates a new button for displaying on the left hand side. */ private JButton createHeaderButton(String text, String iconPath) { Icon icon = new ImageIcon(Editor.class.getResource(iconPath)); JButton button = new JButton(text, icon); button.setBorderPainted(false); button.setContentAreaFilled(false); button.addActionListener(buttonListener); return button; }
/** * Utility method merging 2 icons. */ private static Icon mergeIcons(Icon icon1, Icon icon2, int x, int y, Component c) { int w = 0, h = 0; if (icon1 != null) { w = icon1.getIconWidth(); h = icon1.getIconHeight(); } if (icon2 != null) { w = icon2.getIconWidth() + x > w ? icon2.getIconWidth() + x : w; h = icon2.getIconHeight() + y > h ? icon2.getIconHeight() + y : h; } if (w < 1) w = 16; if (h < 1) h = 16; java.awt.image.ColorModel model = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment (). getDefaultScreenDevice ().getDefaultConfiguration (). getColorModel (java.awt.Transparency.BITMASK); java.awt.image.BufferedImage buffImage = new java.awt.image.BufferedImage (model, model.createCompatibleWritableRaster (w, h), model.isAlphaPremultiplied (), null); java.awt.Graphics g = buffImage.createGraphics (); if (icon1 != null) { icon1.paintIcon(c, g, 0, 0); } if (icon2 != null) { icon2.paintIcon(c, g, x, y); } g.dispose(); return new ImageIcon(buffImage); }
private Icon _getRolloverSelectedIcon() { Icon icon = null; icon = arrowIcons.get( mouseInArrowArea ? ICON_ROLLOVER_SELECTED : ICON_ROLLOVER_SELECTED_LINE ); if( null == icon ) { Icon orig = regIcons.get( ICON_ROLLOVER_SELECTED ); if( null == orig ) orig = regIcons.get( ICON_ROLLOVER ); if( null == orig ) orig = regIcons.get( ICON_NORMAL ); icon = new IconWithArrow( orig, !mouseInArrowArea ); arrowIcons.put( mouseInArrowArea ? ICON_ROLLOVER_SELECTED : ICON_ROLLOVER_SELECTED_LINE, icon ); } return icon; }
protected Icon computeIcon() { ImageIcon icon = BrowserUtils.ICON_INSTANCE; if ((getMode() == HeapWalkerNode.MODE_REFERENCES) && getInstance().isGCRoot()) { icon = BrowserUtils.createGCRootIcon(icon); } return processLoopIcon(icon); }
/** * Return the scalable icon directly (used by {@link IconImageConfigurer}) * * @return */ public Icon getScalableIcon() { synchronized (this) { buildScalableIcon(); } return scalableIcon; }
private void busquedaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_busquedaKeyPressed // TODO add your handling code here: String codigo = ecod.getText(); String apellido = eape.getText(); String nombre = enom.getText(); String direccion = edir.getText(); String telefono = etel.getText(); String colegiado = ecole.getText(); if(codigo.length()==0||apellido.length()==0||nombre.length()==0||direccion.length()==0||telefono.length()==0||colegiado.length()==0) { JOptionPane.showMessageDialog(null, "Los registros no pueden estar vacios\nPor favor llene los registros", "Advertencia", JOptionPane.WARNING_MESSAGE); enom.requestFocus(); } else { if(apellido.length()>50||nombre.length()>50||direccion.length()>50||telefono.length()>12||colegiado.length()>50) { JOptionPane.showMessageDialog(null, "El numero de caracteres en los registros es mayor al permitido\nNombre, Apellido, Direccion y Colegiado no pueden ser mayor a 50 caracteres\nTelefono no puede ser mayor a 12", "Advertencia", JOptionPane.WARNING_MESSAGE); enom.requestFocus(); } else { Icon i = new ImageIcon(getClass().getResource("/Imagenes/Aceptar.jpg")); Medico m = new Medico(eape.getText(), enom.getText(), edir.getText(), etel.getText(), ecole.getText()); JOptionPane.showMessageDialog(null, m.EliminarMedico(m, ecod.getText()),"Mensaje",JOptionPane.INFORMATION_MESSAGE, i); Tabla t = new Tabla(); t.LimpiarTabla(tablaEli); m.PresentarDatos(tablaEli); } } }
private int[] _setIcon(int[] indices, Icon[] icons, final boolean[] widthChanged) { widthChanged[0] = false; boolean fireChange = false; boolean[] changed = new boolean[indices.length]; int changedCount = 0; Arrays.fill(changed, false); boolean[] currWidthChanged = new boolean[]{false}; boolean currChanged = false; for (int i = 0; i < indices.length; i++) { currChanged = _setIcon(indices[i], icons[i], currWidthChanged); fireChange |= currChanged; widthChanged[0] |= currWidthChanged[0]; if (currChanged) changedCount++; changed[i] = currChanged; } int[] toFire; if (widthChanged[0] || fireChange) { if (changedCount == indices.length) { toFire = indices; } else { toFire = new int[changedCount]; int idx = 0; for (int i = 0; i < indices.length; i++) { if (changed[i]) { toFire[idx] = indices[i]; idx++; } } } return toFire; } return null; }
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel listCellRendererComponent = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); listCellRendererComponent.setPreferredSize(new Dimension(50, 20)); if (!(value instanceof Color)) { return listCellRendererComponent; } listCellRendererComponent.setText(""); Color color = (Color) value; Icon iicon = colorMap.get(color); if (iicon == null) { colorMap.put(color, createColoredRectangleIcon(color)); iicon = colorMap.get(color); } listCellRendererComponent.setIcon(iicon); listCellRendererComponent.setBackground(color); if (isSelected && index != -1) { listCellRendererComponent.setBorder(focusBorder); } else { listCellRendererComponent.setBorder(noFocusBorder); } return listCellRendererComponent; }
public static Icon getIcon( String iconPath ) { Icon res = ImageUtilities.loadImageIcon( iconPath, true ); if( null == res ) { Logger.getLogger( TabControlButtonFactory.class.getName() ).log( Level.INFO, "Cannot find button icon: " + iconPath ); } return res; }
public void setIcon(Icon icon) { int oldIconWidth = iconWidth; iconWidth = icon == null ? 0 : icon.getIconWidth(); iconHeight = icon == null ? 0 : icon.getIconHeight(); this.icon = icon; if (oldIconWidth != iconWidth) resetPreferredSize(true, false); }
/** * Load the given image file from an accompanying JAR file, and return it as * an Icon object. */ public static Icon loadIcon(String pathname) { URL url = OurUtil.class.getClassLoader().getResource(pathname); if (url != null) return new ImageIcon(Toolkit.getDefaultToolkit().createImage(url)); return new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB)); }
@Override public Icon getButtonIcon(int buttonId, int buttonState) { Icon res = null; initIcons(); String[] paths = buttonIconPaths.get( buttonId ); if( null != paths && buttonState >=0 && buttonState < paths.length ) { res = TabControlButtonFactory.getIcon( paths[buttonState] ); } return res; }
/** * Maps {@code AbstractButton.getDisabledSelectedIcon()} through queue */ public Icon getDisabledSelectedIcon() { return (runMapping(new MapAction<Icon>("getDisabledSelectedIcon") { @Override public Icon map() { return ((AbstractButton) getSource()).getDisabledSelectedIcon(); } })); }
/** * C'tor * * @param icon * @param al Action to invoke when the button is pressed, can be null but * the button is disabled then. */ public LinkButton(Icon icon, Action a) { setIcon(icon); setPressedIcon(icon); this.handlePopupEvents = true; this.underlined = true; init(a); }
@Override public Image getIcon(int param) { Icon icon = info.getIcon(); if (icon == null) { LOGGER.log(Level.WARNING, "no icon in {0}", info); return super.getIcon(param); } return ImageUtilities.icon2Image(icon); }
private Image getFolderIcon (File file) { FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(file)); Icon icon = null; if (fo != null) { try { ProjectManager.Result res = ProjectManager.getDefault().isProject2(fo); if (res != null) { icon = res.getIcon(); } } catch (IllegalArgumentException ex) { Logger.getLogger(FileTreeView.class.getName()).log(Level.INFO, null, ex); } } return icon == null ? FileTreeView.getFolderIcon() : ImageUtilities.icon2Image(icon); }
@Override public void paintComponent(Graphics g) { if (AppPreferences.ANTI_ALIASING.getBoolean()) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } g.clearRect(0, 0, getWidth(), getHeight()); CanvasTool current = canvas.getTool(); for (int i = 0; i < tools.length; i++) { AbstractTool[] column = tools[i]; int x = ICON_SEP + i * (ICON_SEP + ICON_WIDTH); int y = ICON_SEP; for (int j = 0; j < column.length; j++) { AbstractTool tool = column[j]; if (tool == listener.toolPressed && listener.inTool) { g.setColor(Color.darkGray); g.fillRect(x, y, ICON_WIDTH, ICON_HEIGHT); } Icon icon = tool.getIcon(); if (icon != null) icon.paintIcon(this, g, x, y); if (tool == current) { GraphicsUtil.switchToWidth(g, 2); g.setColor(Color.black); g.drawRect(x - 1, y - 1, ICON_WIDTH + 2, ICON_HEIGHT + 2); } y += ICON_HEIGHT + ICON_SEP; } } g.setColor(Color.black); GraphicsUtil.switchToWidth(g, 1); }
/** * Maps {@code JTabbedPane.addTab(String, Icon, Component, String)} * through queue */ public void addTab(final String string, final Icon icon, final Component component, final String string1) { runMapping(new MapVoidAction("addTab") { @Override public void map() { ((JTabbedPane) getSource()).addTab(string, icon, component, string1); } }); }
private Description( @NonNull final ClassMemberPanelUI ui, @NonNull final String name, @NullAllowed final Union2<ElementHandle<?>,TreePathHandle> handle, @NonNull final ElementKind kind, final int posInKind, @NonNull final ClasspathInfo cpInfo, @NonNull final Set<Modifier> modifiers, final long pos, final boolean inherited, final boolean topLevel, @NonNull Supplier<Icon> icon, @NonNull Openable openable) { Parameters.notNull("ui", ui); //NOI18N Parameters.notNull("name", name); //NOI18N Parameters.notNull("kind", kind); //NOI18N Parameters.notNull("icon", icon); //NOI18N Parameters.notNull("openable", openable); //NOI18N this.ui = ui; this.name = name; this.handle = handle; this.kind = kind; this.posInKind = posInKind; this.cpInfo = cpInfo; this.modifiers = modifiers; this.pos = pos; this.icon = icon; this.isInherited = inherited; this.isTopLevel = topLevel; this.openable = openable; }
private static Icon getRolloverSelectedIconSafe(JRadioButton radio) { Icon icon = radio.getIcon(); if (icon == null) { return getDefaultIcon(); } Icon rolloverSelectedIcon = radio.getRolloverSelectedIcon(); if (rolloverSelectedIcon == null) { rolloverSelectedIcon = radio.getSelectedIcon(); } return (rolloverSelectedIcon != null) ? rolloverSelectedIcon : getIconSafe(radio); }
public static Icon createSmallIcon(Action a) { String iconBase = (String) a.getValue(AbstractEditorAction.ICON_RESOURCE_KEY); if (iconBase != null) { return ImageUtilities.loadImageIcon(iconBase, true); } return null; }
@Override public Image getIcon(int type) { if (description.getCustomIcon() != null) { return ImageUtilities.icon2Image(description.getCustomIcon()); } Icon icon = Icons.getElementIcon(description.getKind(), description.getModifiers()); if (icon != null) { return ImageUtilities.icon2Image(icon); } else { return super.getIcon(type); } }
/** * Loads the icon from the given url. * * @param url * URL pointing to an icon. * @return */ private static Icon load(String url) { // TODO: Why does File.separator force non-relative path names but this // works fine? String prefix = "/resources/"; String file = prefix + url; return new ImageIcon(Icons.class.getResource(file)); }
private static Icon getDefaultOpenIcon() { return UIManager.getIcon("Tree.openIcon"); //NOI18N }
@Override public Icon getIcon() { return isEditor() ? super.getIcon() : Icons.getMainTabIcon(getDisplay().getResourceKind()); }
@Override public Icon loadIcon(String resource, boolean localized) { return ImageUtilities.loadImageIcon(resource, localized); }