jspinner 的 jtable 值未显示

发布于 2024-10-25 00:45:52 字数 2772 浏览 1 评论 0原文

问题是无法获取从 jtable 到 jspinner 显示的值。这是我的 jtablemouseclickedeven

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
if(evt.getClickCount()==1){
    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.getValueAt(jTable1.getSelectedRow(), 4).toString());
}
}

jspinner 格式为 MM/dd/yyyy 所以 jtable 也是...

感谢任何可以再次帮助我的人...

这是我得到的错误:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: illegal value
        at javax.swing.SpinnerDateModel.setValue(SpinnerDateModel.java:440)
        at javax.swing.JSpinner.setValue(JSpinner.java:329)
        at UsernamePasswordPackage.MainForm.jTable1MouseClicked(MainForm.java:930)
        at UsernamePasswordPackage.MainForm.access$1600(MainForm.java:34)
        at UsernamePasswordPackage.MainForm$17.mouseClicked(MainForm.java:337)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
        at java.awt.Component.processMouseEvent(Component.java:6270)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6032)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4247)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

谢谢

problem is can't get the value displayed from jtable to jspinner. here is my jtablemouseclickedeven

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
if(evt.getClickCount()==1){
    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.getValueAt(jTable1.getSelectedRow(), 4).toString());
}
}

jspinner is formatted as MM/dd/yyyy so the jtable also...

thanks to anyone who could help me again...

here is the error i get:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: illegal value
        at javax.swing.SpinnerDateModel.setValue(SpinnerDateModel.java:440)
        at javax.swing.JSpinner.setValue(JSpinner.java:329)
        at UsernamePasswordPackage.MainForm.jTable1MouseClicked(MainForm.java:930)
        at UsernamePasswordPackage.MainForm.access$1600(MainForm.java:34)
        at UsernamePasswordPackage.MainForm$17.mouseClicked(MainForm.java:337)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
        at java.awt.Component.processMouseEvent(Component.java:6270)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6032)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4247)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧伤慢歌 2024-11-01 00:45:52

虽然这是另一个重复,但我会再试一次:您使用 SpinnerDateModel 并传递一个字符串作为值 (jTable1.getValueAt(jTable1.getSelectedRow(), 4).toString()< /code>) 而不是日期。在将字符串传递给微调器之前,将其转换为日期(或者您甚至可能已经获得了日期)。

编辑:我将此答案发布到原始问题,因此版主可能会删除此重复项。

Although this is another duplicate, I'll try again: 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.

Edit: I posted this answer to the original question, so a moderator might delete this duplicate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文