J2SE demo

 

年隔十载,物是人非。

public class Demo extends JFrame {

    public Demo() {
        //setUndecorated(true); //无框显示
        setTitle("U have a dream");
        setLookAndFeel();
        setSize(300, 100);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        FlowLayout flowLayout = new FlowLayout();
        setLayout(flowLayout);
        JButton button1 = new JButton("开始");
        ImageIcon imageIcon = new ImageIcon("images/close.png");
        button1.setIcon(imageIcon);
        JButton button2 = new JButton("停止");
        button2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                System.out.println("hello world");
            }
        });
        
        add(button1);
        add(button2);
        setVisible(true);
    }

    private void setLookAndFeel() {
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new Demo();
    }
}

 

posted @ 2017-03-27 14:23  牧 天  阅读(129)  评论(0)    收藏  举报