配置:Ubuntu 13.04 + Eclipse4.3 + JRE 7
现象:打开一个内嵌AWT/SWING代码的Eclipse 视图,Eclipse直接挂掉
原因:AWT/SWING和SWT都在访问GTK时都使用了锁去保护自己的线程。AWT使用的GTK的锁,但是SWT使用的自己的锁。在使用SWT访问AWT时,就会出错。
解决办法:在使用SWT访问AWT的代码中将以下代码:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
修改为:
if (Platform.WS_GTK.equals(Platform.getWS())) { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
参考: