Mengisi data dari JTable ke JTextField

Referensi Aplikasi Java / Java Application
di dalam JTable itu ada method2 berikut ini yg bisa dipakai sesuai dgn kasusnya:
Code:
int     getSelectedColumn() Returns the index of the first selected column, -1 if no column is selected. int     getSelectedRow() Returns the index of the first selected row, -1 if no row is selected. Object     getValueAt(int row, int column) Returns the cell value at row and column.
jadi kesimpulan tuk ambil sebuah data dalam kolom dan row tertentu bisa spt ini:
Code:
String data = jTable.getValueAt(jTable.getSelectedRow(), jTable.getSelectedColumn());
atau:
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) { try { String datax =String.valueOf(jTable1.getValueAt(jTable1.getSelectedRow(), jTable1.getSelectedColumn())); jTextField1.setText(datax); } catch (Exception e){} }
http://www.goldenstudios.or.id/forum/showthread.php?tid=1808

Share this

Leave a Reply

Your email address will not be published.