Hello all,
I have been facing a problem. I have several ( and i mean several ) class that contains swing elements, implements mouse listener and have a routine called draw. instead of creating new instances of them i declare them in a class as public static and just clear redraw screen. All was fine until suddenly i noticed after redrawing several times they cause multiple event, like a button click does the work of three or more work of the same button click ( tested using system.println()). whats the issue here ?? i can't present the whole source code 'coz it is of 17 files and about 4000 lines altogather (hey not boasting). But i can present u an overview, plz some1 give a solution. thanx in advance.
i hope u can understand this mess.class A implements MouseListener{ /* GUI Elements */ public A(){ .... } draw(){ /* draws the GUI elements on the screen */ } public void mouseClicked(){ CommonData.clearScreen() ; CommonData.a.draw() ; CommonData.b.draw() ; .... so on .... } } class B implements MouseListener{ /* GUI Elements */ public A(){ .... } public draw(){ /* draws the GUI elements on the screen */ } public void mouseClicked(){ CommonData.clearScreen() ; CommonData.a.draw() ; CommonData.b.draw() ; .... so on .... } } class CommonData{ public static A a ; public static B b ; clearScreen() { ... } } class StarttingClass{ public StarttingClass(){ CommonData.a = new A() ; CommonData.b = new B() ; CommonData.a.draw() ; } } class MainClass{ public static void main(String [] args){ javax.swing.SwingUtilities.invokeLater(new Runnable(){ public void run(){ new StarttingClass() ; }) ; } } }