Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Cursor;
import java.awt.Dialog.ModalityType;
import java.awt.Dimension;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;

public class Main {

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setSize(new Dimension(500, 500));

        JDialog dialog = new JDialog(frame, "Export", ModalityType.MODELESS);
        dialog.setSize(300, 300);

        JDialog dialog1 = new JDialog(dialog, "Export", ModalityType.APPLICATION_MODAL);
        dialog1.setSize(200, 200);

        frame.add(new JButton(new AbstractAction("Dialog") {
            @Override
            public void actionPerformed(ActionEvent e) {
                frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                dialog.setVisible(true);
                dialog1.setVisible(true);
            }
        }));
        frame.setVisible(true);
    }
}