I m 遇到麻烦,把javax.swing.JComboBox带入一个org.jdesktop.swingx.JXTable电池。 我提出了以前关于这一问题的问题,但没有得到帮助。
我尝试:
colModel.getColumnExt(HDTableAdapter.STATUS).setCellEditor(editorCB);
colModel.getColumnExt(HDTableAdapter.STATUS).setCellRenderer(rendererCB);
class comboBoxRenderer extends JComboBox implements TableCellRenderer {
public comboBoxRenderer(String[] items) {
super(items);
}
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
setSelectedItem(value);
return this;
}
}
class comboBoxEditor extends DefaultCellEditor {
public comboBoxEditor(String[] items) {
super(new JComboBox(items));
}
}
但是,在这种情况下,我在囚室内得到一个不容置信的ComboBox。