I made a sample testing class of JTable.. and create each data as object based on columnNames.
And i want to put a button in JTable but it's doesn't work.. only show up text(javax.swing.JButton..).
How can i do this.. put a button into JTable??
At the center of non-violence stands the principle of love
.... Martin Luther King, Jr.
Joined: Jun 16, 2009
Hehe.. sorry all, I'm too lazy to think today...
I just remember what i need to display a jbutton in a jtable..
I have to make my own TableCellRenderer, get component which return component as the renderer.. and next step is to make TableModel that implement the return because DefaultTableModel is designed to work with "DefaultTableCellRenderer" that return string...
And final step is creating buttonmouselistener for action..
I've read your clue.. So what you have written in your class is basicly to specify column that is used to contain the button so renderer and editor can perform invoke action based on row number of clicked button...
Hmm... great thought...
What that i want to point in my previous message is to handle what DefaultTableCellRenderer can't handle if return value is component..so we have to customize to get getTableCellRendererComponent() which returns a java.awt.Component that knows how to draw the contents of a specific cell.
To maintain the column is the job of TableCellRenderer, it will return same component for every cell of the column..
I think that the simply way to implement a button in a table..