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
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