Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   need to know how to give movements/actions.. (http://www.programmingforums.org/showthread.php?t=3965)

gonc May 18th, 2005 1:26 PM

need to know how to give movements/actions..
 
HeLLo..i have a java project about graphics..the project is about designing a kitchen..i easiLy made the designing the kitchen's objects..i am aLso asked to give some movements to the objects..but i am stuck with giving the actions and movements..for exampLe when i click to the oven with the mouse the coLor can change..or some other movements..:)i think you understand my probLem..can someone pLease heLp me with this:(thanx a Looott..

gonc..

mackenga May 20th, 2005 3:19 PM

Sounds like what you need to learn about is event handling in Java. Start with Sun's tutorial, http://java.sun.com/docs/books/tutorial/index.html, and you'll find something useful I'm sure.

Edit:
In fact, http://onesearch.sun.com/search/clic...ve&col=javadoc is the page that covers event handling and graphics. Should be a good starting point.

Mjordan2nd May 20th, 2005 4:35 PM

You should check out ActionListener and MouseListener as well.

gonc May 25th, 2005 4:14 AM

stiLL stuck:(
 
i have checked out pages..but i am stiLL stuck with the action Listener event for giving the motions and movements..:(

Mjordan2nd May 28th, 2005 1:02 AM

Well, if you're looking for, lets say, a mouse click in a certain location to change the oven's color, then you could say, in the mouseClicked(Event e) method:

:

/* minX, maxX, minY, maxY for oven range are defined above*/
 
 
 int xLoc = e.getX();
 int yLoc = e.getY();
 if(x > minX && x<maxX && y>minY && y < maxY)
 {
          changeColor();
 }


That's somewhat how it should look. Of course, you'd have to define all those variables, and the changeColor() method.


All times are GMT -5. The time now is 12:57 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC