I am able to display the buttons fine in a JTable; but I am having problems clicking on the button. I tried implementing a mouse listener for the JPanel but that does not work.
This is how i create my table:
Object[] columnnames = {
"ID", "Resource Name", "Incident", "Owner", "Action"
};
Object[][] sentByMe = //get data;
sentByMeTable =
new JTable(sentByMe, columnnames){
public TableCellRenderer getCellRenderer( int row, int column ) {
return new PlusMinusCellRenderer();
}
};
And this is my PlusMinusCellRenderer
class PlusMinusCellRenderer extends JPanel implements TableCellRenderer {
public Component getTableCellRendererComponent(
final JTable table, Object value,
boolean isSelected, boolean hasFocus,
int row, int column) {
this.add( new JLabel( value.toString() ) );
JButton button = new JButton("+");
this.add(button);
return this;
}
So what i am having trouble with is being able to click on the buttons. Thanks for all your help in advance.