Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class Main {

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JButton button = new JButton("Button");
        frame.add(button);

        frame.setAlwaysOnTop(true);
        frame.setSize(500, 500);
        frame.setLocation(500, 500);

        button.addActionListener(e -> {
            JOptionPane optionPane = new JOptionPane("Option Pane");
            optionPane.showMessageDialog(frame, "Message!");
        });

        frame.setVisible(true);
    }
}