Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Pixel Listener

 
David Bauer
Greenhorn
Posts: 2
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,

i want to create a program that is reacting on some pixels and is increasing a counter when a selected pixel is changed. Im using the Robot class for it. cause this:

is killing my pc, i am looking for another way. I guess its possible with listeners. but i got no idea how. any solutions?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35753
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,
This is the java.awt.Robot class, right? It doesn't have listeners because it is designed largely for triggering events. You could add a Thread.sleep to your loop and have it check only once a second. A listener would be better though. I'll add this to the AWT forum as well.
 
David Bauer
Greenhorn
Posts: 2
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I am looking for some other ways to solve my problem (creating a program that is increasing a counter whenever a selected pixel is changing his color).

Thank you for moving!
 
Rob Camick
Ranch Hand
Posts: 2703
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess its possible with listeners.


I'm not aware of any such listener.

whenever a selected pixel is changing his color


Why does the pixel change its color? Is this something your program is doing?

Pixels don't just randomly change there color unless your program is doing some process. So I'm guessing a better solution (to reduce CPU usage) is to track the pixel color before and after the processing your program is doing.
 
Norm Radder
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If another program is changing the color at that location, you can have your program check it periodically.  Less time spent sleeping between checks will use more CPU.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!