I tried to create a table and manipulate it. but I do not understand what code should I write in my netbeans.
JTextField1 variable n JButton1 Variable ok JTable1 Variable tabel1
on JButton1 or Ok Button I give code like this:
private void okActionPerformed(java.awt.event.ActionEvent evt) {
int key = Integer.parseInt(n.getText());
c.setText(String.valueOf(key));
DefaultTableModel dtm = (DefaultTableModel) tabel1.getModel();
for(int i = 0; i < key; i++){
int r = tabel1.getRowCount()+1;
dtm.setRowCount(r);
}
}
with code that I write, I managed to make the line corresponds to the number on JTextField1.
but when i press the ok button continuously. rows in the table continues to grow.
how can i make that row in the table according to Jtextfield1 and no longer grow?
thanks before.