java help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: java help

  1. #1
    Join Date
    Oct 2005
    Posts
    2

    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.

  2. #2
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    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.

  3. #3
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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

  1. Replies: 2
    Last Post: 06-14-2006, 03:16 PM
  2. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 06:46 AM
  3. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 05:32 PM
  4. Replies: 0
    Last Post: 01-31-2002, 11:08 PM
  5. Re: VB vs. Visual Age for Java
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center