【发布时间】:2012-10-03 04:15:04
【问题描述】:
我创建了我自己的所见即所得编辑器,它由一个设计窗口和一个工具调色板窗口组成。 设计窗口是一个 JFrame,工具面板是一个 JDialog,其中 FocusableWindowState 设置为 false。 但是,通过将 FocusableWindowState 切换为 false,我不再能够在工具面板窗口上编辑 JTable 中的单元格。将其更改为 true 允许我编辑单元格。
这是我的代码示例:
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(0, 0, 1024, 768);
JDialog paletteWindow = new JDialog(frame, false);
paletteWindow.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
paletteWindow.setResizable(false);
paletteWindow.setFocusableWindowState(false);
paletteWindow.setBounds(1024, 0, 320, 768);
JTable grid = new JTable(new DefaultTableModel(new String[] {"Name", "Value"}, 5));
paletteWindow.getContentPane().add(new JScrollPane(grid));
frame.setVisible(true);
paletteWindow.setVisible(true);
即使 FocusableWindowState 设置为 false,我如何仍能编辑单元格?
【问题讨论】:
-
嗨 Cobus,请发布与您的问题相关的代码,以便我们为您提供帮助。
-
工具栏可以创建一个可浮动的窗口,但它仍然具有可聚焦的窗口状态,并在您单击它时获取焦点。