jcombobox as cell editor java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location

后端 未结 4 1395
天命终不由人
天命终不由人 2021-01-19 10:20

I am using a custom JComboBox as a cell editor in a JTable. When the users gets to the cell using keyboard controls it tries to open the popup. This causes the following e

4条回答
  •  长情又很酷
    2021-01-19 11:11

    If you embed your instruction inside a try .. catch instruction , your program will run without problems:

    SwingUtilities.invokeLater(new Runnable(){
    
                            public void run()
                            {
                            try {
                            tInput.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
                            tInput.showPopup();
                            }
                            catch   (IllegalComponentStateException e) {
                                    return;
                                    }
    
                              }
                     }); 
    

提交回复
热议问题