我有一個JBtable,並在我想插入一個按鈕的列之一。JBTable ColumnInfo與按鈕
我嘗試如下:
private class DeleteColumn extends ColumnInfo<Field, JButton> {
public DeleteColumn() {
super("Delete");
}
@Nullable
@Override
public JButton valueOf(final Field field) {
final JButton removalButton = new JButton();
removalButton.setText("-");
removalButton.addActionListener((e) -> {
// do something
});
return removalButton;
}
@Override
public Class<?> getColumnClass() {
return JButton.class;
}
}
然而,當這個被渲染,它仍然只是顯示的ToString()將JButton的。如何在表格中顯示按鈕?
的確如此。謝謝 – mangusbrother