JSpinner (Time) in JTable

前端 未结 2 1194
长情又很酷
长情又很酷 2020-12-07 06:07

I am trying to implement an JSpinner for time in to a JTable , it worked preaty goot at the first look but after losing the focus of the cell the edited cell is being set to

2条回答
  •  隐瞒了意图╮
    2020-12-07 06:45

    You are confusing Editors and Renderers. Editor is a widget displayed when a cell is being edited. When the cell is no longer edited, the cell renderer is used to "paint" the cell. This is all explained in this paragraph. I would really recommend you to read it, as it explains clearly how table rendering is performed.

    What you should do, is use a Custom CellRenderer for the involved column so that it uses your date formatter.

    Take a look at this tutorial for more information on cell editors and cell renderers.

提交回复
热议问题