• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pixel Listener

 
Greenhorn
Posts: 2
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic