Example usage for javax.swing LookAndFeel makeIcon

List of usage examples for javax.swing LookAndFeel makeIcon

Introduction

In this page you can find the example usage for javax.swing LookAndFeel makeIcon.

Prototype

public static Object makeIcon(final Class<?> baseClass, final String gifFile) 

Source Link

Document

Creates and returns a UIDefault.LazyValue that loads an image.

Usage

From source file:LookAndFeelMakeIcon.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Lazy Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Object iconObject = LookAndFeel.makeIcon(LookAndFeelMakeIcon.class, "yourFile.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);//from w w  w .j av a  2 s  .c  o  m
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Lazy Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Object iconObject = LookAndFeel.makeIcon(MainClass.class, "yourImage.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    Integer fifteen = new Integer(15);
    Object lazyArgs[] = new Object[] { Color.GREEN, Boolean.TRUE, fifteen, fifteen };
    Object lazyDiamond = new UIDefaults.ProxyLazyValue("DiamondIcon", lazyArgs);
    UIManager.put("Tree.openIcon", lazyDiamond);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);// w  w w .  ja v  a 2s.  c o  m
    frame.setVisible(true);
}

From source file:LazySample.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Lazy Example");

    Object iconObject = LookAndFeel.makeIcon(LazySample.class, "World.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    Integer fifteen = new Integer(15);
    Object lazyArgs[] = new Object[] { Color.green, Boolean.TRUE, fifteen, fifteen };
    Object lazyDiamond = new UIDefaults.ProxyLazyValue("DiamondIcon", lazyArgs);
    UIManager.put("Tree.openIcon", lazyDiamond);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    Container contentPane = frame.getContentPane();
    contentPane.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);/*w w w.j  a  v a2  s.c  o  m*/
    frame.setVisible(true);
}