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();
        JButton button = new JButton("Click me");
        button.addActionListener(e -> JOptionPane.showMessageDialog(frame, "Hello World!"));
        frame.getContentPane().add(button);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}