List of utility methods to do Swing Icon
ImageIcon | createTransparentIcon(int width) create Transparent Icon final Image image = new BufferedImage(width, width, BufferedImage.TYPE_4BYTE_ABGR); return new ImageIcon(image); |
Icon | darken(Icon icon) Returns a slightly darker version of the icon. BufferedImage img = getBufferedImageFromIcon(icon); if (img == null) return icon; BufferedImageOp op = new RescaleOp(0.75f, 0, null); return new ImageIcon(op.filter(img, null)); |
Icon | emptyIcon(final int width, final int height) Returns an icon with a given size and no content. return new Icon() { public int getIconWidth() { return width; public int getIconHeight() { return height; public void paintIcon(Component c, Graphics g, int x, int y) { ... |
List | getApplicationIcons() get Application Icons if (tnicon == null) { tnicon = new ArrayList<Image>(); tnicon.add( new ImageIcon(ClassLoader.getSystemClassLoader().getResource("tn5250j-16x16.png")).getImage()); tnicon.add( new ImageIcon(ClassLoader.getSystemClassLoader().getResource("tn5250j-32x32.png")).getImage()); tnicon.add( new ImageIcon(ClassLoader.getSystemClassLoader().getResource("tn5250j-48x48.png")).getImage()); ... |
Icon | getBadgedIcon(Icon icon, Icon badge) get Badged Icon int sHeight = badge.getIconHeight(); int sWidth = badge.getIconWidth(); return getBadgedIcon(icon, badge, sWidth / 2, sHeight / 2); |
JButton | getbtnIcon(String iconpath) getbtn Icon JButton button = new JButton(); button.setIcon(new ImageIcon(iconpath)); button.setBorder(null); button.setFocusPainted(false); button.setContentAreaFilled(false); return button; |
JButton | getbtniconpresspress(String Iconpath1, String pressIconpath2, String pressIconpath3) getbtniconpresspress JButton button = new JButton(); button.setIcon(new ImageIcon(Iconpath1)); button.setPressedIcon(new ImageIcon(pressIconpath2)); button.setPressedIcon(new ImageIcon(pressIconpath3)); button.setBorder(null); button.setFocusPainted(false); button.setContentAreaFilled(false); return button; ... |
I | getClosestIcon(Collection icons, int height) From the given icons, chooses the icon taller than (if available) and closest to the given height. I icon = null; if (icons != null) { int diff = 0; for (I i : icons) { int d = i.getIconHeight() - height; if (d == 0) { return i; if (icon == null || (diff < 0 && d > diff) || (diff > 0 && d < diff && d >= 0)) { icon = i; diff = d; return icon; |
Icon | getDefaultIcon() get Default Icon BufferedImage bi = new BufferedImage(18, 18, 3); Graphics2D g2 = bi.createGraphics(); g2.setBackground(Color.red); g2.clearRect(0, 0, bi.getWidth(), bi.getHeight()); g2.setColor(Color.white); g2.setStroke(new BasicStroke(2.0F)); GeneralPath x = new GeneralPath(); x.moveTo(0.0F, 0.0F); ... |
Image | getDefaultIcon() Get the default Icon, which is the icon for a file. return DEFAULT_ICON;
|