MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.LookAndFeel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;

public class MainClass {
    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);
        frame.setVisible(true);
    }
}