This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes help me it is a simple code but i need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help me it is a simple code but i need help" Watch "help me it is a simple code but i need help" New topic
Author

help me it is a simple code but i need help

Ashutosh Raikvar
Greenhorn

Joined: Feb 13, 2012
Posts: 3

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

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Feb 13, 2012
Posts: 3

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

Joined: Oct 02, 2003
Posts: 11153
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3418
    
  12
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.


Joanne
Ashutosh Raikvar
Greenhorn

Joined: Feb 13, 2012
Posts: 3
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help me it is a simple code but i need help
 
Similar Threads
Beginners question (Head First - TwoButtons)
Head First Java Question - GUI program TwoButtons
why does this code fail?
TwoButtons App From "HeadFirst Java" Book
Simple Gui Question (Head First Java)