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
  • 37,241
  • 25
  • 195
  • 267
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
  • 203,806
  • 29
  • 246
  • 1,045
  • 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,680
  • 3
  • 46
  • 47