当应用程序启动时,没有任何行被选中。 但是我想表明第一行已经被选中。 这个怎么做? 我需要在JTable设置一行的颜色吗? 更新:我试过table.setRowSelectionInterval(0,0)。 我知道它应该工作,但有一个错误消息: Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Row index out of range at javax.swing.JTable.boundRow(Unknown Source) at javax.swing.JTable.setRowSelectionInterval(Unknown Source) at cpn_gui.OptPanel.createForm(OptPanel.java:124) at cpn_gui.OptPanel.<init>(OptPanel.java:50) at cpn_gui.Login$1.actionPerformed(Login.java:62) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) […]