Mouse listener?

Hello,Could someone help me write the code for the following simple command? I still have no clue how to do it after reading some tutorialsWhen a person clicks the mouse, initiate this method
[212 byte] By [glock3a] at [2007-11-27 4:55:11]
# 1

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class MouseListenerDemo {

public static void main(String[] args) {

final JFrame frame = new JFrame("Demo");

JLabel label = new JLabel("Click anywhere");

Container c = frame.getContentPane();

c.setLayout(new FlowLayout());

c.add(label);

c.addMouseListener(new MouseAdapter() {

public void mouseClicked(MouseEvent e) {

JOptionPane.showMessageDialog(frame, "You clicked me!");

}

});

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.pack();

frame.setVisible(true);

}

}

shittybytesa at 2007-7-12 10:10:03 > top of Java-index,Java Essentials,Java Programming...
# 2

> Could someone help me write the code for the

> following simple command? I still have no clue how to

> do it after reading some tutorials

>

> When a person clicks the mouse, initiate this method

There are plenty samples of this code out there, and we could write more, but to what purpose? The bigger question and the one you need to clarify is this: Exactly what part of the mouseListener code samples confuse you?

petes1234a at 2007-7-12 10:10:03 > top of Java-index,Java Essentials,Java Programming...
# 3
The above code worked :)Thanks
glock3a at 2007-7-12 10:10:03 > top of Java-index,Java Essentials,Java Programming...