TableCellEditor Problem

I am trying to get a JXDatePicker to inside of a table cell. What I end up with in a date in what looks like a drop down box. I should see the button to select a new dat with.

Here is the CellRender

publicclass DateSelectorCellRendererextends JXDatePickerimplements

TableCellRenderer{

/**

*

*/

privatestaticfinallong serialVersionUID = 1427951948870190513;

public DateSelectorCellRenderer(){

super();

}

public Component getTableCellRendererComponent(JTable table, Object value,

boolean isSelected,boolean hasFocus,int row,int column){

returnthis;

}

}

Here is the table

publicclass PendingOffenseTableextends JXTable{

/**

*

*/

publicstaticfinal String OUTCOMEBLUESLIP ="Print Blue Slip";

publicstaticfinal String OUTCOMEPENDING ="Pending";

privatestaticfinallong serialVersionUID = 6567059604918401586;

private Context ctx;

public PendingOffenseTable(Context cont){

this.ctx = cont;

this.setDragEnabled(true);

this.setColumnSelectionAllowed(true);

PendingOffenseTableModel model =new PendingOffenseTableModel(ctx);

this.setModel(model);

this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

this.setColumnControlVisible(true);

this.packAll();

this.setHighlighters(new HighlighterPipeline(

new Highlighter[]{ AlternateRowHighlighter.classicLinePrinter}));

this.getHighlighters().addHighlighter(

new RolloverHighlighter(Color.BLACK, Color.WHITE ));

this.setRolloverEnabled(true);

setUpDateColumn(this.getColumnModel().getColumn(3));

setUpOutcomeColumn(this.getColumnModel().getColumn(5));

}

publicvoid setUpOutcomeColumn(TableColumn outcomeColumn){

//Set up the editor for the sport cells.

JComboBox comboBox =new JComboBox();

comboBox.addItem("");

comboBox.addItem(PendingOffenseTable.OUTCOMEBLUESLIP);

comboBox.addItem(PendingOffenseTable.OUTCOMEPENDING);

outcomeColumn.setCellEditor(new DefaultCellEditor(comboBox));

//Set up tool tips for the outcome cells.

DefaultTableCellRenderer renderer =

new DefaultTableCellRenderer();

renderer.setToolTipText("Click to Change Outcome");

outcomeColumn.setCellRenderer(renderer);

}

publicvoid setUpDateColumn(TableColumn dateColumn){

DateSelectorCellRenderer render =new DateSelectorCellRenderer();

dateColumn.setCellRenderer(render);

}

I donnot think it matters but here is the model

publicclass PendingOffenseTableModelextends AbstractTableModel{

/**

*

*/

privatestaticfinallong serialVersionUID = -3805136146648292471;

private Context ctx;

publicfinal String[] COLUMN_NAMES =new String[]{"Offense Type" ,"Section","Day","Date","Time","Outcome","Demerits"};

public PendingOffenseTableModel(Context cont){

this.ctx = cont;

}

/* (non-Javadoc)

* @see javax.swing.table.TableModel#getRowCount()

*/

publicint getRowCount(){

return 3;

}

publicint getColumnCount(){

return COLUMN_NAMES.length;

}

public String getColumnName(int columnIndex){

return COLUMN_NAMES[columnIndex];

}

/* (non-Javadoc)

* @see javax.swing.table.TableModel#getValueAt(int, int)

*/

publicvoid setValueAt(Object aValue,int rowIndex,int columnIndex){

}

public Object getValueAt(int row,int col){

switch(row)

{

case 0:

switch(col)

{

case 0:

return"Absence from class";

case 1:

return"OT101-2";

case 2:

return"Tuesday";

case 3:

return"";

case 4:

return"3:00 PM";

case 5:

return PendingOffenseTable.OUTCOMEBLUESLIP;

case 6:

return 15;

default:

returnnew String("Error");

}

case 1:

switch(col)

{

case 0:

return"Absence from chapel";

case 1:

return"";

case 2:

return"Thursday";

case 3:

return"";

case 4:

return"11:00 AM";

case 5:

return PendingOffenseTable.OUTCOMEPENDING;

case 6:

return 25;

default:

returnnew String("Error");

}

case 2:

switch(col)

{

case 0:

return"Absence from class";

case 1:

return"";

case 2:

return"Wednesday";

case 3:

return"";

case 4:

return"6:30 PM";

case 5:

return PendingOffenseTable.OUTCOMEPENDING;

case 6:

return 10;

default:

returnnew String("Error");

}

default:

returnnew String("Error");

}

}

publicboolean isCellEditable(int row,int col)

{returntrue;}

}

[11687 byte] By [LORDs_diakonosa] at [2007-10-2 22:33:15]
# 1
And where is your question?
mvpa at 2007-7-14 1:50:40 > top of Java-index,Desktop,Core GUI APIs...
# 2
I don't am not selling teh whole component I only see a date in a dropdown. I should see a date with teh button next to it
LORDs_diakonosa at 2007-7-14 1:50:40 > top of Java-index,Desktop,Core GUI APIs...
# 3
Is your JXDatePicker object is a panel with all the swing components you are expecting inside it? Can you check it?If you're trying to change the date, I think you should use TableCellEditor than TableCellRenderer.
debajyotibanerjeea at 2007-7-14 1:50:40 > top of Java-index,Desktop,Core GUI APIs...
# 4

It's hard to tell without seein the JXDatePicker code, but it looks like you took a cell editor, adapted it into a cell RENDERER, and then only set it as a renderer?

If it does, infact, implement TableCellEditor and you want to use it as an editor, you have to add it as an editor in the same place you add it as a renderer

msullya at 2007-7-14 1:50:40 > top of Java-index,Desktop,Core GUI APIs...
# 5
And if it doesn't implement TableCellEditor, then you need to change your subclass - there are a few more interface methods for Editor than renderer.
msullya at 2007-7-14 1:50:40 > top of Java-index,Desktop,Core GUI APIs...