1.當用戶從JComboBox中選擇項目時,它們被添加到JTable中,我創建了JComboBox和Jtable。
2.我不想讓用戶選擇他以前在JComboBox中選擇的項目。
3.所選選項必須禁用(不可選)。我應該怎麼做?下面的代碼4.刪除所選的JComboBox從項目已在JTable中添加了之後,但我感興趣的禁用它在運行時禁用JComboBox項目
String getchoice=(String)selectedgames_combobox.getSelectedItem();
DefaultTableModel gamesmodel = new DefaultTableModel();
//adding selected choices from JComboBox in JTable
gamesmodel.addColumn("Selected Games");
gamesmodel.insertRow(gamesmodel.getRowCount(),new Object[]{ getchoice }) ;
//refreshing table
games_table.setModel(gamesmodel);
//removing the selected item from JComboBox
selectedgames_combobox.removeItem(getchoice);
另請參見[禁用JList的項目](http://stackoverflow.com/a/8344497/1048330) – tenorsax 2013-02-13 16:58:44
請參閱[如何禁用JComboBox中的某些項目](https://stackoverflow.com/questions/23722706/how-to-disable-certain-items-in-a-jcombobox)。 – 2017-11-16 12:38:23