Test.java Source code

Java tutorial

Introduction

Here is the source code for Test.java

Source

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;

public class Test extends JFrame {
    public static void main(String[] argv) {
        Test window = new Test();
        window.setVisible(true);
    }

    public Test() {
        this.setBounds(100, 100, 200, 100);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel panel = new JPanel();
        panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.LOWERED, Color.lightGray, Color.yellow));
        //panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.RAISED, 
        //  Color.lightGray, Color.yellow));
        //panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.LOWERED, 
        //  Color.lightGray, Color.lightGray, Color.white, Color.orange));

        this.setLayout(new FlowLayout());

        JButton exitButton = new JButton("Exit");
        panel.add(exitButton);
        this.add(panel);

        exitButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent event) {
                System.exit(0);
            }
        });
    }
}