title: show jtable on button click
body: <p>I'm trying to show table , dynamically fill the row data in a for loop and show , this on button click.
  Here is my code, can somebody help me please.</p>
  
  <pre><code>public class GetQuotes {
  
      private JTextField wtField = new JTextField(10);
      private JTextField htField = new JTextField(10);
      private JTextField lnField = new JTextField(10);
      private JTextField wiField = new JTextField(10);
      final JPanel gui = new JPanel(new BorderLayout(2,3));
      JPanel labelFields = new JPanel(new BorderLayout(2,2));
      JTable table;
      JPanel guiCenter = new JPanel(new BorderLayout(2,3));
      //default constructor
      public GetQuotes(){
  
      labelFields.setBorder(new TitledBorder("Enter Inputs"));
  
      JPanel labels = new JPanel(new GridLayout(0,1,1,1));
      //labels.setBorder(new TitledBorder("GridLayout"));
      JPanel fields = new JPanel(new GridLayout(0,1,1,1));
  
       labels.add(new JLabel("Weight"));
       labels.add(new JLabel("Length"));
       labels.add(new JLabel("Width"));
       labels.add(new JLabel("Height"));
  
       fields.add(wtField);
       fields.add(lnField);
       fields.add(wiField);
       fields.add(htField);
  
        labelFields.add(labels,BorderLayout.CENTER);
        labelFields.add(fields,BorderLayout.EAST);
  
  
       JPanel buttonConstrsint = new JPanel(new FlowLayout(FlowLayout.CENTER));
       JButton getQuotesButton = new JButton("Get Quotes..");
  
        getQuotesButton.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
  
                     Quote[] data = getData();
  
                      table = new JTable(generateTableModel(data));
                      table.setModel(generateTableModel(data));
  
                      JScrollPane pane = new JScrollPane(table);
                      guiCenter.add(pane, BorderLayout.SOUTH);
  
                      gui.add(guiCenter,BorderLayout.CENTER);
  
  
                 }
  
              }
          });
  
      buttonConstrsint.add(getQuotesButton);
      guiCenter.add(buttonConstrsint,BorderLayout.NORTH);
  
      gui.add(labelFields,BorderLayout.NORTH);
      gui.add(guiCenter,BorderLayout.CENTER);
  
      JOptionPane.showMessageDialog(null, gui);
  
  
      }
  
      private Quote[] getData(){
  
          //this function returns the needed data
  
      }
  
      //test the class
      public static void main(String[]args) throws Exception{
          SwingUtilities.invokeLater(new Runnable(){
              public void run(){
                  new GetQuotes();
              }
          });
  
          }
  
      public static TableModel generateTableModel(Quote[] dataa) {
  
          String[][] data = new String[100][2] ;
            String[] colNames = {"col1","col2"};
  
          //here how to add another column data  dataa[j].getPrice 
            for(int i=0; i&lt;colNames.length; i++){
            for(int j=0; j&lt;dataa.length; j++){
                data[j][i] = dataa[j].getServiceName();
  
            }
            }
  
          return new DefaultTableModel(data, colNames);
      }
  }
  </code></pre>
  
  <p>1) I need help in filling rowData in for loop in generateTableModel function. At the moment I can fill single column data, how to build the second column data.</p>
  
  <p>2) once table constructed here and returned back to actionperformed function above, where I'm adding table to jscrollpanel and to the guicenterpanel.
  But somehow that doesn't show the table.</p>
  
  <p>can somebody help me please.</p>