-
java help
hi guys i need sum help creating a little programme.
when the mouse is in the box the colour has to change to black and when the mouse is outside the box the colour has to change to red. This has to be on loop.
I startd it of something like dis:
import element.*;
import java.awt.Color;
public class age
{
public static void main(String args[])
{
DrawingWindow d = new DrawingWindow();
Rect r = new Rect(25,05,18,1;
d.setForeground(Color.red);
d.fill(r);
}
}
this code only creates the box need helping with the rest changing colour when the mouse is in and out the box.
-
To detect mouse movements etc you will need to use a MouseListener of some kind.
There have been several sample programs with listeners on the forum, so do a search for the different mouse listeners and you should get lots of examples of code to look at.
-
You'll find that the MouseListener class has MOUSE_ENTERED and MOUSE_EXITED events which allow you to capture when the mouse has entered or left your component. Just capture the event and then fire the appropriate color change.
Similar Threads
-
Replies: 2
Last Post: 06-14-2006, 03:16 PM
-
Replies: 1
Last Post: 05-13-2005, 06:46 AM
-
By Mike Tsakiris in forum .NET
Replies: 11
Last Post: 10-04-2002, 05:32 PM
-
By Anonymous in forum Java
Replies: 0
Last Post: 01-31-2002, 11:08 PM
-
By JJ in forum Enterprise
Replies: 1
Last Post: 07-06-2000, 04:50 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks