Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JColorChooser;
import javax.swing.JDialog;

public class Main {
    public static void main(String[] argv) {
        final JColorChooser chooser = new JColorChooser();
        ActionListener okListener = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                Color newColor = chooser.getColor();
            }
        };

        ActionListener cancelListener = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                Color newColor = chooser.getColor();
            }
        };

        boolean modal = false;

        JDialog dialog = JColorChooser.createDialog(null, "Dialog Title", modal, chooser, okListener,
                cancelListener);

        dialog.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent evt) {
                Color newColor = chooser.getColor();
            }
        });
    }
}