4

I'm working on a possibility to zoom into a UI. Therefore I can't access the components directly and have to catch the events on glasspane.

This works fine as long as I don't use auto-updating-components as JTextArea. Since this is an exam I can't use an external library for zooming.

The caret updating is my actual problem, so I'm looking for an option to get all events without having to attach a listener to the component.

There existed a SwingEventMonitor but I can't find it in Java6 anymore. Is the class just renamed? I can add AWTListener via Toolkit.getToolkit().. but since CaretEvent is a SwingEvent it seems like I can't cantch it this way.

Cœur
  • 34,719
  • 24
  • 185
  • 251
Banshee
  • 175
  • 1
  • 1
  • 12

2 Answers2

3

It's not as convenient, but you can intercept all AWTEvent subclasses entering the EventQueue by pushing your own queue, as shown here.

Community
  • 1
  • 1
trashgod
  • 200,320
  • 28
  • 229
  • 974
  • with notice that, all waitng events in EventQueueu should be removed and replaced with action(s) from this brutteForce +1 – mKorbel Jun 11 '11 at 11:22
  • @mKrbel: Yes, brute force, but comprehensive. I struggled with the wording; does this read better? – trashgod Jun 11 '11 at 16:25
2

Use the SwingWorker instead. Here is an example.

Costis Aivalis
  • 13,490
  • 3
  • 48
  • 46