I created my own WYSIWYG editor, which consists of a design window and a tool palette window. The project window is a JFrame, and the tool palette is a JDialog with FocusableWindowState set to false. However, by switching FocusableWindowState to false, I can no longer edit cells in JTable in the window of my tool palette. Changing it to true allows me to edit cells.
Here is my sample code:
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);
How can I edit cells even if FocusableWindowState is set to false?
source share