0

Is there a way to add AWT listener to a SWT component?

I previously made an app running mostly in AWT and Swing components. Now, I have hotkeys function which is dependent on a custom-made library that listens to global key events and returns its corresponding AWT key code.

My problem arises when I shifted the whole app and used SWT components instead. As we know some of the keys returns a different key code now, which messes up the whole hotkeys function.

The initial solutions I've thought of are:

A. Use javax.swing.jtextfield as mycomponent listener instead of swt.widget.text

B. Add AWT listener to SWT component (if possible)

C. Create a class which re-maps all AWT keycodes to SWT and vice-versa.

I believe these are feasible solutions. I just want to check out with you guys if you have a brilliant idea on which I could work with. I'm only new to java and I could use some professional insights on this.

(besides, I think A is cheating. B I could not find a way to do yet. And C is a hassle job to do)

Cheers.

4

1 回答 1

0

经过一番谷歌搜索后,我找到了 JBoss Tools 的类,它可能会帮助您将 AWT 键码映射到 SWT 键码。

请参阅JaCoCo 项目中的KeyboardHelper 类

于 2013-03-20T12:31:00.870 回答