• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help me it is a simple code but i need help

 
Ashutosh Raikvar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

IMPLEMENTING-ANIMATION
what i want:-
i want the text(on left)to change when i press R.H.S button and animation(a circle moving downwards) to run when i press South side button.
what i am getting:-
what i am getting is rapid movement of circle also when i press LHS which has no relation with the circle thing the color of circle changes.
some1 plse help me......
thanks in adv T_T
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) never use Thread.sleep in Swing's EDT, use a Timer

2) int x=70,y=70;
should be in DrawPanel, that way the class can be re-used in applets, frames etc,
as is, it can't.

3) do you really want the color of the background and ball to change 20 times per second?
and at random times when the panel is painted? (this happens more often than most realize)

4) class Label implements ActionListener
is really a poor choice for a name - there exists an awt class Label = confusion/conflict

that should do for starters
 
Ashutosh Raikvar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

here is some other working code (with animation working and no major GUI).my code has flaws i would appreciate if you change it to work the way i want it to work.one more thing above code i copied from head-first java book
 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added code tags to both your posts. Notice how it is now context high-lighted, and the formatting is preserved? This make it MUCH easier to read.

Next time, after you past your code in, highlight it all and hit the little 'code' formatting button - just like you wanted to make it italic or bold.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashutosh Raikvar wrote:here is some other working code (with animation working and no major GUI).my code has flaws i would appreciate if you change it to work the way i want it to work.one more thing above code i copied from head-first java book

And what would you learn if someone did that for you ? It's much better if you make the changes you need and then if you come across a specific problem you can ask about it here.
 
Ashutosh Raikvar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right now i dont have sufficient knowledge of java programming so i guess i will be able to identify the problem after spending more time programming.thanks for every thing
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic