Hey guys,
I've successfully created some buttons and menu items that change the text on a label (hurray!) but have no idea how to respond to when the frame itself is click (double clicked in this case). I am assuming some sort of listener but everything I find is either for component, window, or internal JFrames - they only deal with minimise, expand, open, close, etc.
How do I do something when the frame itself is double clicked?
Code for creation of JFrame:
public Frame() {
//calls the superclass constructor passing as a parameter the title of the frame.
super("Frame");
//Creates the msglabel, adds it to the frame and sets an initial message.
msgLabel = new JLabel("Click a button", JLabel.CENTER);
getContentPane().add(msgLabel, BorderLayout.CENTER);
initializeButtons();
initializeMenu();
getContentPane().setBackground(new Color(255, 255, 208));
pack();
setSize(300,200);
setResizable(false);
setVisible(true);
}
Note: a lot of that code is not mine, given to us as part of the lab exercise. :P
Posts
I'll take a look at mouseListener, thanks.
EDIT: Solved. Thanks fforde - I completely glazed over the fact that a double click is from a mouse, therefore a listener should be looking at the mouse (oops).