Order of events

M

marcussilfver

I am trying to distinguish between a combobox selection made
programatically and a combobox selection made by the user. I have code
like the following:

comboBox1.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt) {
comboBox1Clicked = true;
}
});

comboBox1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (comboBox1Clicked)
{
System.out.println("This selection was made by the user");
comboBox1Clicked = false;
}
else
System.out.println("This selection was made by the program");
}
});

This seems to be working fine. I am not confident though that it will
always do that.

In which order will events be fired? Will the mouseClicked event
always be fired before the actionPerformed event?
I need it to always work on both Windows and Mac OS.

thanks
 
J

Jeff Higgins

marcussilfver said:
I am trying to distinguish between a combobox selection made
programatically and a combobox selection made by the user. I have code
like the following:

comboBox1.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt) {
comboBox1Clicked = true;
}
});

comboBox1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (comboBox1Clicked)
{
System.out.println("This selection was made by the user");
comboBox1Clicked = false;
}
else
System.out.println("This selection was made by the program");
}
});

This seems to be working fine. I am not confident though that it will
always do that.

Just out of curiosity, can the user select items with key strokes?
 
M

marcussilfver

marcussilfverwrote:




Just out of curiosity, can the user select items with key strokes?





- Visa citerad text -- Dölj citerad text -

- Visa citerad text -

No, Why do you wonder?
 
J

Jeff Higgins

marcussilfver wrote:
Jeff said:
Just out of curiosity, can the user select items with key strokes?

No, Why do you wonder?

I wondered whether to categorize selection by keystroke
as user selection or programmatic selection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top