0

I'm trying to set JDateChooser(com.toedter.calendar.JDateChooser) into JTable row. When I put this render in empty program it looks and works perfect. But when I'm trying to add this render to JTable,generated by Swing-constructor it loses proportions and sizes. I do same steps to add render,but get different result.

https://i.stack.imgur.com/TlwtU.png

 table.setDefaultEditor(Date.class,new JDateChooserCellEditor1() );//how i add render to Tables
public class JDateChooserCellEditor1 extends AbstractCellEditor implements
    TableCellEditor { //render class
private JDateChooser dateChooser = new JDateChooser();
public Component getTableCellEditorComponent(JTable table, Object value,
        boolean isSelected, int row, int column) {
    Date date = null;
    if (value instanceof Date)
        date = (Date) value;
    dateChooser.setDate(date);
    dateChooser.setDateFormatString("yyyy-MM-dd");      
    return dateChooser;}
public Object getCellEditorValue() {
    return dateChooser.getDate();}}
camickr
  • 321,443
  • 19
  • 166
  • 288
Sashok
  • 1
  • 2
  • 1
    The data chooser is not a renderer, it is an editor. A renderer just displays the data in the cell. The editor will be a popup dialog that allows you to change the day in the cell. Read the section from the Swing tutorial on [Using Other Editors](https://docs.oracle.com/javase/tutorial/uiswing/components/table.html#editor). It has a working example of using the JColorChooser as a popup editor. – camickr Nov 09 '20 at 15:36
  • @camickr , thank you for answer. May be I used wrong words to describe class which I used. Solution was in * look and feel*(about difference of tables look) – Sashok Nov 16 '20 at 05:55

0 Answers0