Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class Main {
    public static void main(String[] args) {
        final JFrame frame = new JFrame();
        JOptionPane pane = new JOptionPane("Some message", JOptionPane.QUESTION_MESSAGE,
                JOptionPane.YES_NO_OPTION) {
            @Override
            public void setValue(Object newValue) {
                super.setValue(newValue);
                JOptionPane.showMessageDialog(frame.getContentPane(), "You have hit " + newValue);
            }
        };
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new BorderLayout());
        frame.add(new JLabel("Some panel in the middle"), BorderLayout.CENTER);
        frame.add(pane, BorderLayout.SOUTH);
        frame.pack();
        frame.setVisible(true);
    }
}