jTableから14行のデータをTextfieldに配置するのに問題がありますか?私はコーディングに新しいです。java.lang.ArrayIndexOutOfBoundsException:7> = 7
try {
String data = jSubject.getSelectedItem().toString();
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:dist/Database/./h2database/recordDB", "test", "test");
Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
String sql = "Select * from " + data;
ResultSet rs = st.executeQuery(sql);
DefaultTableModel a = (DefaultTableModel) jTable2.getModel();
a.setRowCount(0);
while (rs.next()) {
String q = rs.getString("Subjects");
a.addRow(new Object[]{q});
}
JTableHeader th = jTable2.getTableHeader();
TableColumnModel tcm = th.getColumnModel();
TableColumn tc = tcm.getColumn(0);
tc.setHeaderValue("Subjects");
th.repaint();
DefaultTableModel xa = (DefaultTableModel) jTable2.getModel();
// int selectedRowIndex = jTable2.getSelectedRow();
s1.setText(xa.getValueAt(0, 0).toString());
s2.setText(xa.getValueAt(1, 0).toString());
s3.setText(xa.getValueAt(2, 0).toString());
s4.setText(xa.getValueAt(3, 0).toString());
s5.setText(xa.getValueAt(4, 0).toString());
s6.setText(xa.getValueAt(5, 0).toString());
s7.setText(xa.getValueAt(6, 0).toString());
s8.setText(xa.getValueAt(7, 0).toString());
s9.setText(xa.getValueAt(8, 0).toString());
s10.setText(xa.getValueAt(9, 0).toString());
s11.setText(xa.getValueAt(10, 0).toString());
s12.setText(xa.getValueAt(11, 0).toString());
s13.setText(xa.getValueAt(12, 0).toString());
s14.setText(xa.getValueAt(13, 0).toString());
} catch (ClassNotFoundException ex) {
Logger.getLogger(CBL.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(CBL.class.getName()).log(Level.SEVERE, null, ex);
}
私はそれは常に私にjava.lang.ArrayIndexOutOfBoundsExceptionを与えるコード実行するたび:7> = 7エラーが。
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 7 >= 7
at java.util.Vector.elementAt(Vector.java:474)
at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:648)
at progress.chart.CBL.jSubjectActionPerformed(CBL.java:1750)
at progress.chart.CBL.access$1600(CBL.java:34)
at progress.chart.CBL$19.actionPerformed(CBL.java:1041)
at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1258)
at javax.swing.JComboBox.setSelectedItem(JComboBox.java:586)
at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:622)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:861)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopup.java:510)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
これは、あなたたちはあなたのコードでミスをしたように見えます
ポストスタックトレース。 –
ここに完全なエラーリストを貼り付けてください –
今すぐ見てください –