aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to make a proper button listener? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to make a proper button listener?" Watch "How to make a proper button listener?" New topic
Author

How to make a proper button listener?

Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
Hello I've created some code to do the following:
1)It creates a frame and a panel.
2)A background image is added to the panel.
3)The panel is then added to the frame.
4)Then a image ( a jpg) moves from one point to
another on the panel. It move in a continuous motion from one point to another.
Ok the code below does the above. It should be noted that the code belows works perfectly. Examine to code and then I'll tell you what I trie dto extend the code to do and the problem I encounterd.

Ok note that was soon as the program is executed the small image ( VAN.jpg) starts to move in a smoothe motion (using the for loop) from one point to another.
However I do not want it to start right away. Instead I want to add a button to another frame and only when that button is pressed only then does the VAN.jpg image starts to move..only when that button is pressed. The code below is what I did to try to implement this. However when I ran the code below and the button was pressed the VAN.jpg picture moved to its final position and only then was it shown. That is - the user did not see the image move continously from one point to another. All the user sees is the image in its final position after the button was pressed.
Can someone tell me what am doing wrong. Thanks a million. Here is the code.



yours respectfully<br />Avin Sinanan
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Hello,
If you'd include all of the code (class Calculation is missing), I'd be glad to test it and let you know what I figure out. Otherwise, my guessing abilities are too limited at this hour.
Good Luck,
-Dirk Schreckmann


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
Hello Dirk this is the missing Calculation class
..thanks again
Atually here is the full code again...

[ March 11, 2002: Message edited by: Avin Sinanan ]
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Avin,
You will need to make a new Thread to have your image move along. Change your Move class to the one below and enjoy.

Regards,
Manfred.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to make a proper button listener?