Example usage for javax.swing GrayFilter createDisabledImage

List of usage examples for javax.swing GrayFilter createDisabledImage

Introduction

In this page you can find the example usage for javax.swing GrayFilter createDisabledImage.

Prototype

public static Image createDisabledImage(Image i) 

Source Link

Document

Creates a disabled image

Usage

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    ImageIcon icon = new ImageIcon("yourFile.gif");

    Image normalImage = icon.getImage();
    Image grayImage = GrayFilter.createDisabledImage(normalImage);
    Icon warningIcon = new ImageIcon(grayImage);
    JLabel warningLabel = new JLabel(warningIcon);

    JLabel label3 = new JLabel("Warning", icon, JLabel.CENTER);

    frame.add(warningLabel, "Center");
    frame.add(label3, "South");

    frame.setSize(300, 200);/*from ww w  .j  a va 2s.  c  om*/
    frame.setVisible(true);
}

From source file:JTextAreaBackgroundSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Background Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final ImageIcon imageIcon = new ImageIcon("yourFile.gif");
    JTextArea textArea = new JTextArea() {
        Image image = imageIcon.getImage();

        Image grayImage = GrayFilter.createDisabledImage(image);
        {//from w w w .ja  va2s . c  o  m
            setOpaque(false);
        }

        public void paint(Graphics g) {
            g.drawImage(grayImage, 0, 0, this);
            super.paint(g);
        }
    };
    JScrollPane scrollPane = new JScrollPane(textArea);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(250, 250);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Background Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final ImageIcon imageIcon = new ImageIcon("draft.gif");
    JTextArea textArea = new JTextArea() {
        Image image = imageIcon.getImage();

        Image grayImage = GrayFilter.createDisabledImage(image);
        {/*from   w w w.  j a  va  2  s.  co m*/
            setOpaque(false);
        }

        public void paint(Graphics g) {
            g.drawImage(grayImage, 0, 0, this);
            super.paint(g);
        }
    };
    JScrollPane scrollPane = new JScrollPane(textArea);
    Container content = frame.getContentPane();
    content.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(250, 250);
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel p = new JPanel();
    ImageIcon icon = new ImageIcon("r.gif");

    JButton b1 = new JButton("Regular", icon);
    p.add(b1);/*from   w  ww .jav a 2s . c  om*/

    Image image = GrayFilter.createDisabledImage(icon.getImage());
    JButton b2 = new JButton("GrayFilter", new ImageIcon(image));
    p.add(b2);

    getContentPane().add(p);

    pack();
    setVisible(true);
}

From source file:edu.ku.brc.ui.IconManager.java

/**
 * Creates a Black and White image from the color
 * @param img the image to be converted//ww w.  j a v a 2 s  .  c o m
 * @return new B&W image
 */
public static ImageIcon createFadedImage(final ImageIcon icon) {
    Image image = GrayFilter.createDisabledImage(icon.getImage());
    return new ImageIcon(image);

    /*BufferedImage bi = new BufferedImage(img.getIconWidth(), img.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics g = bi.createGraphics();
    g.drawImage(img.getImage(), 0, 0, null);
    g.setColor(new Color(255, 255, 255, 128));
    g.fillRect(0, 0, bi.getWidth(), bi.getHeight());
    ImageIcon icon = new ImageIcon(bi);
    g.dispose();
    return icon;*/
}

From source file:org.wings.STabbedPane.java

/**
 * Inserts a <i>component</i>, at <i>index</i>, represented by a
 * <i>title</i> and/or <i>icon</i>, either of which may be null.
 * Uses java.util.ArrayList internally, see insertElementAt()
 * for details of insertion conventions.
 * @param title the title to be displayed in this tab
 * @param icon the icon to be displayed in this tab
 * @param component The component to be displayed when this tab is clicked.
 * @param tip the tooltip to be displayed for this tab
 * @param index the position to insert this new tab
 *
 * @see #addTab//from w  ww.  jav a 2  s  . com
 * @see #removeTabAt
 */
public void insertTab(String title, SIcon icon, SComponent component, String tip, int index) {

    SIcon disabledIcon = null;

    if (icon != null && icon instanceof SImageIcon) {
        disabledIcon = new SImageIcon(
                new ImageIcon(GrayFilter.createDisabledImage(((SImageIcon) icon).getImage())));
    }

    String t = (title != null) ? title : "";

    Page p = new Page(t, icon, disabledIcon, component, tip);
    pages.add(index, p);

    contents.addComponent(p.component, p.component.getComponentId());

    if (pages.size() == 1) {
        setSelectedIndex(0);
    }
}