开发者

JTable date value to jspinner

i have displayed a date value formatted MM/dd/yyyy and i want it to display to jsinner on jtablemouseclickedevent. how would i do that? i tried it with this code but i get an error:

my jtable has 5 columns

ID = int type
Username = String type
Password = String type
Website = String type
Date Encoded = date/time type (MM/dd/yyyy)

this is my code:

jLabel5.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString());
jTextField4.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 1).toString());
jTextField5.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 2).toString());
jTextField6.setText(jTable1.getValueAt(jTable1.getSelectedRow(), 3).toString());
**jSpinner1.setValue(jTable1.getValueA开发者_如何学编程t(jTable1.getSelectedRow(), 4));**

any help would be greatly appreciated :) :) :)


You use SpinnerDateModel and pass a String as the value (jTable1.getValueAt(jTable1.getSelectedRow(), 4).toString()) instead of a date. Convert the string to a date (or maybe you even got a date already) before passing it to the spinner.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜