Solved

Java Mouse trigger!

Posted on 1997-03-21
1
169 Views
Last Modified: 2006-11-17
I would like to write a applet including a textfield and a mouse.  When move the mouse pointer over the textfield, the text in the color of the text in the textfield will be changed to another color.  Can anyone tell me what is the algorithm?
0
Comment
Question by:benson031397
1 Comment
 
LVL 2

Accepted Solution

by:
majkl earned 100 total points
ID: 1219108
First you must extend TextField, and there watch for actions.
I have tried this code, but it doesn't work. It seems, tha Textfield cannot react to mouse move.
Other components can.

Here is example :
class MY extends TextField
{
   public boolean mouseMove(java.awt.Event evt, int x, int y)  

    {
         System.out.println("moved");
       return true;
    }
   
   public boolean handleEvvent(Event event)
     {

        if (event.id == Event.MOUSE_MOVE)
          {
               System.out.println("moved");
          }
        return true;  
     }

In this way you can generraly do it for all components in the same way.
I was also surprisedm that Texfield doesn't work, but I think that was also one discusion in NewsGroups.
Hope you will help me with scores although it does'nt work

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 90
JDeveloper 12c for 32 bit 4 84
Java SE 8u111  Lot of stuff broke 11 68
print map entry 34 67
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question