Example usage for java.awt Window addMouseListener

List of usage examples for java.awt Window addMouseListener

Introduction

In this page you can find the example usage for java.awt Window addMouseListener.

Prototype

public synchronized void addMouseListener(MouseListener l) 

Source Link

Document

Adds the specified mouse listener to receive mouse events from this component.

Usage

From source file:processing.app.Base.java

/**
 * Show the About box.//from  w  w w  . jav  a2 s .  com
 */
@SuppressWarnings("serial")
public void handleAbout() {
    final Image image = Theme.getLibImage("about", activeEditor, Theme.scale(475), Theme.scale(300));
    final Window window = new Window(activeEditor) {
        public void paint(Graphics graphics) {
            Graphics2D g = Theme.setupGraphics2D(graphics);
            g.drawImage(image, 0, 0, null);

            Font f = new Font("SansSerif", Font.PLAIN, Theme.scale(11));
            g.setFont(f);
            g.setColor(new Color(0, 151, 156));
            g.drawString(BaseNoGui.VERSION_NAME_LONG, Theme.scale(33), Theme.scale(20));
        }
    };
    window.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            window.dispose();
        }
    });
    int w = image.getWidth(activeEditor);
    int h = image.getHeight(activeEditor);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    window.setBounds((screen.width - w) / 2, (screen.height - h) / 2, w, h);
    window.setLocationRelativeTo(activeEditor);
    window.setVisible(true);
}