问题描述
我在JInternalFrame
中有一个JDesktopPane
。
在那里面,我有几个JTextField
和JTextArea
。
任何键盘快捷键都不能在我的任何内部框架中使用...例如:Cmd+C
/ Cmd+V
,甚至Cmd+A
,都跳到行首,等等。
是否要启用某些设置以允许键盘快捷键在内部框架内工作?
我的Swing应用程序只是一个简单的工具,可以将xml格式转换为字符串。复制粘贴输入是其中的重要部分。
我正在从应用程序中添加一些代码段...但是我认为我没有编写任何专门禁用键盘快捷键的代码。
//sample create
private JTextField tfPattern = new JTextField("*.*");
private JTextArea taLog = new JTextArea();
private JScrollPane spLog = new JScrollPane(taLog);
//sample add
outer.add(tfPattern,"spanx 2,wrap");
outer.add(spLog,"span");
//MigLayout for the panels
private JPanel outer = new JPanel(new MigLayout( "","[fill][450:700:,grow,fill][fill]","[][][80::100,fill][][][][][80::100,fill][][300::,fill][]" ));
//Mac menu bar setting
System.setProperty("apple.laf.useScreenMenuBar","true");
//Installing WebLaf at the beginning
WebLookAndFeel.install();
//beginning of app I setup font scaling
private static void setupFontScaling() {
for (Map.Entry<Object,Object> entry : javax.swing.UIManager.getDefaults().entrySet()) {
Object key = entry.getKey();
Object value = javax.swing.UIManager.get(key);
if (value != null && value instanceof javax.swing.plaf.FontUIResource) {
javax.swing.plaf.FontUIResource fr=(javax.swing.plaf.FontUIResource)value;
javax.swing.plaf.FontUIResource f = new javax.swing.plaf.FontUIResource(fr.deriveFont(fr.getSize2D() * 0.9f));
javax.swing.UIManager.put(key,f);
}
}
}
更新: 发布问题后意识到WebLaf可能是问题。 注释了WebLaf安装的行,现在复制/粘贴有效。
但是,WebLaf过去可以与JFrames一起正常工作。想知道为什么JInternalFrames和WebLaf会出现问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)