0

I want to update a jtable depending on the info provided in the text fields and on clicking jbutton. Each row of the jtable should be updated on clicking the button one time. I am able to update the first row by giving apt data[actual-row][actual-col]. But I need help for creating the same for every row using some loop or collection.

btn7.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
{
new Thread() 
{
public void run() 
{
data[1][0] = tf1.getText().substring(tf1.getText().lastIndexOf('-                                                                                   ')+1,tf1.getText().length() );  
data[1][1] = tf2.getText();
data[1][2] = tf3.getText();
data[1][3] = tf4.getText();
data[1][4] = tf5.getText();
data[1][5] = tf6.getText();
data[1][6] = tf7.getText().substring(0,tf7.getText().lastIndexOf(' ')+1);
data[1][7] = (String)cb.getSelectedItem();
data[1][8] = tf8.getText();
}
}.start();

enter image description here

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • 1
    Construct and manipulate Swing GUI objects _only_ on the [event dispatch thread](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html). If this is not a duplicate, please edit your question to include a [mcve] that shows your revised approach. – trashgod Feb 22 '17 at 07:55
  • 1
    Almost close. I was finding the logic.Thank you. – Sufyan Ahamed Feb 22 '17 at 09:29

0 Answers0