M
marcussilfver
Hi
I have an application developed according to MVC. The models
implements one or more interfaces and invokes the listeners (views)
when updated. In one listener method that is invoked by an updated
model I have code that removes all radiobuttons kept in Vectors and
then creates a new bunch of radiobuttons in the Vectors.
It also does a
addMouseListener(new MouseAdapter() {
public void mouseClicked(mouseEvent evt){
System.out.println("I was clicked");
}
});
to add eventhandling to be executed when the user clicks a
radiobutton
My problem is that when executing my application and clicking a
radiobutton then the mouseClicked method is executed 6 times!! When I
set a breakpoint at the System.out.println("I was clicked"); line then
I can see when execution reaches that line that I have 6
AWTEventMulticaster.mouseClicked(MouseEvent) invokations on the call
stack.
The row above the addMouseListener row is a
System.out.println("Entering..."); statement
When I choose to continue execution the application stops on the
breakpoint 6 times.
"Entering..." is printed only once. But "I was clicked" is printed 6
times.
I searched my project and I dont explicitly use AWTEventMulticaster
anywhere in my code.
I guess I have multiple threads somehow and from what I have read,
Swing is not threadsafe.
Does someone know how I can get only one invocation of mouseClicked
per clicked radiobutton?
thanx
I have an application developed according to MVC. The models
implements one or more interfaces and invokes the listeners (views)
when updated. In one listener method that is invoked by an updated
model I have code that removes all radiobuttons kept in Vectors and
then creates a new bunch of radiobuttons in the Vectors.
It also does a
addMouseListener(new MouseAdapter() {
public void mouseClicked(mouseEvent evt){
System.out.println("I was clicked");
}
});
to add eventhandling to be executed when the user clicks a
radiobutton
My problem is that when executing my application and clicking a
radiobutton then the mouseClicked method is executed 6 times!! When I
set a breakpoint at the System.out.println("I was clicked"); line then
I can see when execution reaches that line that I have 6
AWTEventMulticaster.mouseClicked(MouseEvent) invokations on the call
stack.
The row above the addMouseListener row is a
System.out.println("Entering..."); statement
When I choose to continue execution the application stops on the
breakpoint 6 times.
"Entering..." is printed only once. But "I was clicked" is printed 6
times.
I searched my project and I dont explicitly use AWTEventMulticaster
anywhere in my code.
I guess I have multiple threads somehow and from what I have read,
Swing is not threadsafe.
Does someone know how I can get only one invocation of mouseClicked
per clicked radiobutton?
thanx