Java 8 Icon - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Icon class.

This code example shows how to use the following methods:getIconHeight, getIconWidth, paintIcon
                public int getIconWidth() { 
                    return size;
                } 
 
                public void paintIcon( Component c, Graphics g, int x, int y ) {
                    BufferedImage img = new BufferedImage(icon.getIconWidth(),icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB );
                    // we can cache the img when aaime gets out a profiler and tells us it is worthwhile 
                    icon.paintIcon( c, img.getGraphics(), 0, 0 );
                     
                    if( c != null ){
                        g.drawImage( img, x, y, size, size, c.getBackground(), c );
                    } 
                    else { 
                        g.drawImage( img, x, y, size, size, c );
                    }                     
                }                 
            }; 
        }         
    }     
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIconHeight, getIconWidth
 
  private void chooseImage() throws MalformedURLException {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.showOpenDialog(this);
    Path file = fileChooser.getSelectedFile().toPath();
    Icon imageIcon = new ImageIcon(file.toUri().toURL());
    setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight() + 100);
    imageLabel.setIcon(imageIcon);
    String decodeText = getDecodeText(file);
    textArea.setText(decodeText);
  } 
 
  private static String getDecodeText(Path file) {
    BufferedImage image;
    try { 
      image = ImageReader.readImage(file.toUri());
    } catch (IOException ioe) {
      return ioe.toString();
    } 
    LuminanceSource source = new BufferedImageLuminanceSource(image);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIconHeight, getIconWidth, paintIcon
        // Make a brighter version of the icon, and cache it. 
        rollover = ImageManipulator.brighten(icon);
        if(rollover == null)
            BUTTON_CACHE.put(rolloverName, NULL);
        else 
            BUTTON_CACHE.put(rolloverName, rollover);
         
        return rollover;
    }    
     
    private static Properties loadButtonNameMap() {
        Properties p = new Properties();
        URL url = ResourceManager.getURLResource("icon_mapping.properties");
        InputStream is = null;
        try { 
            if(url != null) {
                is = new BufferedInputStream(url.openStream());
                p.load(is);
            } 
        } catch(IOException ignored) {

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIconHeight, getIconWidth, paintIcon
        Graphics2D g2d = (Graphics2D)g;
        RenderingHints oldHints = g2d.getRenderingHints();
        AffineTransform oldTransform = g2d.getTransform();
        g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                             RenderingHints.VALUE_RENDER_QUALITY);
        double xscale = (double)getIconWidth() / icon.getIconWidth();
        double yscale = (double)getIconHeight() / icon.getIconHeight();
        g2d.translate(x, y);
        g2d.scale(xscale, yscale);
        try { 
            icon.paintIcon(c, g, 0, 0);
        } 
        finally { 
            g2d.setTransform(oldTransform);
            g2d.setRenderingHints(oldHints);
        } 
    } 
 
    public int getIconWidth() { 
        return width;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIconHeight, getIconWidth, paintIcon
        this.icon = icon; 
        shadowIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon)icon).getImage())); 
    }  
  
    public int getIconHeight(){  
        return icon.getIconWidth(); 
    }  
  
    public int getIconWidth(){  
        return icon.getIconHeight(); 
    }  
  
    public void paintIcon(Component c, Graphics g, int x, int y){ 
      Color highlight = UIManager.getColor("VLDocking.highlight");
      Color shadow = UIManager.getColor("VLDocking.shadow");
      g.setColor(highlight);
      g.fillRect(x, y, getIconWidth(), getIconHeight());
      shadowIcon.paintIcon(c, g, x + shadowWidth-1, y + shadowHeight-1); 
      icon.paintIcon(c, g, x-1,  y-1); 
    }  

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIconHeight, getIconWidth, paintIcon
        } 
    } 
 
    // Draws the icon centered at (x,y) 
    protected void drawCentered(Component c, Graphics graphics, Icon icon, int x, int y) {
		icon.paintIcon(c, graphics,
				x - icon.getIconWidth()  / 2 - 1,
				y - icon.getIconHeight() / 2);
    } 
 
 
    // Helper Code ************************************************************ 
 
    private void updateLineStyle(Object lineStyle) { 
        linesEnabled = !Options.TREE_LINE_STYLE_NONE_VALUE.equals(lineStyle);
    } 
 
    // Listens for changes of the line style property 
    private class LineStyleHandler implements PropertyChangeListener {
        public void propertyChange(PropertyChangeEvent e) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIconHeight, getIconWidth, paintIcon
    private static Image getImage(Icon icon) {
        if(icon instanceof ImageIcon) {
            return ((ImageIcon)icon).getImage();
        } else { 
            BufferedImage buffer = new BufferedImage(
                icon.getIconWidth(), icon.getIconHeight(),
                BufferedImage.TYPE_INT_ARGB);
            Graphics g = buffer.getGraphics();
            icon.paintIcon(new JLabel(), g, 0,0);
            g.dispose();
            return buffer;
        } 
    } 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIconHeight, getIconWidth
JLabel splash = new JLabel(logo);
		layers = new JLayeredPane(); 
		layers.add(splash, Integer.valueOf(0));
		getContentPane().add(layers);
		int width = logo.getIconWidth();
		int height = logo.getIconHeight();
		layers.setBounds(0, 0, width, height);
		splash.setBounds(0, 0, width, height);
		int h = progressBar.getFontMetrics(progressBar.getFont()).getHeight();
		currentTask.setBounds(TEXT_INDENT, height-3*h, width, h);
		progressBar.setBounds(0, height-2*h, width, h);
		 
		addToLayer(currentTask);
		addToLayer(progressBar);
	} 
	 
	/**  
	 * Sets the default for the window.  
	 *  
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIconHeight, getIconWidth, paintIcon
 
    private BufferedImage createMask(Icon mask) {
        // create a BufferedImage to paint the mask into so that we can later retrieve pixel data 
        // out of the image. 
        BufferedImage image = new BufferedImage(
                mask.getIconWidth(), mask.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
 
        Graphics graphics = image.getGraphics();
        mask.paintIcon(null, graphics, 0, 0);
        graphics.dispose();
 
        return image;
    } 
 
    public Icon getIcon() {
        return WindowUtils.isParentWindowFocused(this) || fInactiveIcon == null
                ? super.getIcon() : fInactiveIcon;
    } 
 
    @Override 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIconHeight, getIconWidth, paintIcon
  private Icon createDisabledIcon(){
    if (defaultIcon instanceof ImageIcon){
      Image i = GrayFilter.createDisabledImage (((ImageIcon)defaultIcon).getImage());
      return new ImageIcon(i);
    } else { 
      BufferedImage bi = new BufferedImage(defaultIcon.getIconWidth(), defaultIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
      Graphics g = bi.createGraphics();
      g.setColor(new Color(0,0,0,0));
      g.fillRect(0,0, defaultIcon.getIconWidth(), defaultIcon.getIconHeight());
      defaultIcon.paintIcon(null, g, 0,0);
      g.dispose();
      Image i = GrayFilter.createDisabledImage(bi);
      return new ImageIcon(i);
    } 
  } 
 
  public int getIconWidth() { 
    int w = 0;
    if (defaultIcon != null){
      w = Math.max(w, defaultIcon.getIconWidth());
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 Icon Methods: