How to code Auto mouse color function in Java

Asked By 30 points N/A Posted on -
qa-featured

I'm thinking of a Java program that would recognize the text on the screen as the cursor hovers. By that, the background color would automatically change based on the text. For example, as the mouse points to text "black", the background would be black. How could I do this auto mouse color function?

SHARE
Best Answer by Shifflett Laurel
Best Answer
Best Answer
Answered By 0 points N/A #194911

How to code Auto mouse color function in Java

qa-featured

Hellow Crewe Bob,

My aim is to give you the basic idea of MouseOver to change anything by an example

I have created input files consisting of three fields

Height                    Width              Text_to_Show

50                           100                  Shifflett

                                               

I am constructing an exclusive function ‘GradientPaint’ by ‘new’ keyword.When the function create two

Rectangles and a user moves the mouse over the rectangle then the  text message attached to it:- Like for  row 50,100  will be seen as  "Shifflett".

 

 

 

for(int i=0; i<myarraylist.size(); i++)

{

 

               Coloring fc = myarraylist.get(i);

                                             

 

GradientPaint gpi = new GradientPaint(0, 0,c.getColor() , 0, 20, Color.white, true

                                              g2d.setPaint(gpi);

                                              g2d.drawRect(fc.value1, 29, fc.mywidth, 83);

                                              g2d.fillRect(fc.value1, 29, fc.mywidth, 83);

                                              fc.addMouseMotionListener(this);

                                              fc.addMouseListener(this);

                                                                                                          

                                                            

}

 

Thanking you

Shifflett Laurel

 

Answered By 0 points N/A #194910

How to code Auto mouse color function in Java

qa-featured

Hello Bob,

Here is javascript code for changing the background color with mouse over the text.

<script language="JavaScript">
function changeBGC(color)

{
document.bgColor = color;
}
</script>

<a href="#" onMouseOver="javascript:changeBGC('# 000000')">Black</a>

I hope that this script will help you.

Answered By 0 points N/A #194909

How to code Auto mouse color function in Java

qa-featured

Hi,
I provide a Java code for you that can help you to click on the submit button then it gets executed.

This code includes the getPixel Color method and pass the x and y coordinate values as argument and this will return the rgb color information on that particular coordinate location.

The Java code is attached.

Thanking you
Franke Mary

Login/Register to Answer

Related Questions