I have a JTable
that just contains one item which is a JButtton
that has an icon which is set to the JFreeChart
generated chart.
If you click the button it launches a new window with the JFreeChart
chart.
I have a cell renderer for the button which simply returns the JButton
object that contains the chart item.
If I single click on the button it will launch the new window.
But if I double click on the button the new window launches, but the icon on the button, which used to be the JFreeChart
, changes to just a text string with the class name path of the JButton
with the class field values.
They other way I can get this behavior to happen is if I remove the cell renderer then the JButton
just diplays the class name. So I'm not sure what is going on and have played around with it a ton and haven't made any progress. I was going to post some code but there is just too much of it.
If anybody has any ideas, I can post certain sections of code to help explain.
Here is code:
Class init {
...
ItModel itModel = new ItModel ();
JTable table = new JTable(itModel );
TableRendrend rend = new TableRend();
table.getColumn("it").setCellRenderer(rend);
}
class TableRend implements TableCellRenderer {
JButton itButton;
...
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int columns){
if(itButton ==null){
itButton = new JButton (JButton)value.getIcon();
}
return itButton;
}
}
Class itModel extends AbstractTableModel{
JButton button;
...
public Object getValueAt(int rowIndex, intColumnIndex){
if(button==null){
button = new JButton( new ImageIcon(JFreeChartImage.getImage()));
}
return button
}
}
This all works except when double clicking on the JButton and it displays TEXT ex.
javax.Swing.JButton(0,0,...)
all field values instead of the the actual chart image that should be displayed