title: JTextField's setText method does not update the JTextField instances
body: <p>The below is part of code of a multi file project. I am posting only this code since I am unclear why setText method is not working. Not all code for this project is included.</p>
  
  <pre><code>        import javax.swing.*;
          import javax.swing.event.*;
          import java.awt.*;
          import java.awt.event.*;
  
          @SuppressWarnings("serial")
  
          public class Controller extends JFrame implements ActionListener,ListSelectionListener 
          {
  
              private JButton addButton;
              private JButton deleteButton;
              private JButton viewDetailsButton;
              private JPanel btnsPnl = new JPanel();
              private JPanel mainPnl = new JPanel();
              private JPanel dataPnl = new JPanel();
              private JPanel listPnl = new JPanel();
              private JLabel loanIdLabel = new JLabel("LoanId");
              private JLabel loanName = new JLabel("Loan Name");
              private JLabel loanLender = new JLabel("Lender");
              private JLabel loanAmount = new JLabel("Loan Amount");
              private JTextField loanIdFld = new JTextField(15);
              private JTextField loanNameFld = new JTextField(15);
              private JTextField lenderFld = new JTextField(15);
              private JTextField loanamountFld = new JTextField(15);
              private DefaultListModel dlm = new DefaultListModel();
              private JList jlst=new JList(dlm);
  
              private loansModel model;
              private loansView loansView;
  
              private int selectedListIndex;
              private ListSelectionModel listSelectionModel;
  
  
          public loansController(loansModel mo)
          {
             addButton = new JButton("Add Loan");
             deleteButton = new JButton("Delete Loan");
             viewDetailsButton = new JButton("View Details of all Loans");
             model = mo;
             loansView = new loansView(mo);   
          }
  
          /* Builds GUI for the controller component of the
           *  Model-View-Controller implementation
           */
          public void buildGUI()
          {
              GridBagLayout gbl = new GridBagLayout();
              GridBagConstraints gbc = new GridBagConstraints();
              gbc.gridx=0;
              gbc.gridy=0;
              dataPnl.setLayout(new GridLayout(4,2));
              dataPnl.add(loanIdLabel);
              dataPnl.add(loanIdFld);
              dataPnl.add(loanName);
              dataPnl.add(lenderFld);
              dataPnl.add(authorLabel);
              dataPnl.add(authorFld);
              dataPnl.add(priceLabel);
              dataPnl.add(loanamountFld); 
              gbl.setConstraints(dataPnl, gbc);
              mainPnl.add(dataPnl);    
              Dimension listDim = new Dimension(50,90);
              jlst.setPreferredSize(listDim);
              gbc.gridx = 0;
              gbc.gridy = 1;
              gbl.setConstraints(listPnl,gbc);
              listPnl.add(jlst);
              listSelectionModel= jlst.getSelectionModel();
              listSelectionModel.addListSelectionListener(new loansController(model));
              gbc.gridx=1;
              gbc.gridy=1;
              gbc.gridwidth=2;
              gbl.setConstraints(btnsPnl,gbc);    
              addButton.addActionListener(this);
              deleteButton.addActionListener(this);
              viewDetailsButton.addActionListener(this);
              btnsPnl.add(addButton);
              btnsPnl.add(deleteButton);
              btnsPnl.add(viewDetailsButton);
              mainPnl.add(listPnl);
              mainPnl.add(btnsPnl);
              getContentPane().add(mainPnl);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setSize(800,400);
              setVisible(true);
          }
  
          /* Handles events coming from add,delete, and view Details 
           * buttons */
          public void actionPerformed(ActionEvent ae)
          {
  
              if (ae.getSource()==addButton)
              {
                  String bId = loanIdFld.getText();
                  String titFld = lenderFld.getText();
                  String authFld = authorFld.getText();
                  String priFld = loanamountFld.getText();
                  boolean isAnumber;
                  isAnumber = isNumeric(priFld);
  
                  if (!isAnumber)
                  {
                      JOptionPane.showMessageDialog(null, 
                          "Enter the correct loan amount",
                          "Error: Price entry",
                           JOptionPane.INFORMATION_MESSAGE);
                      priFld = loanamountFld.getText();
                      isAnumber = isNumeric(priFld);
  
                  }
  
                  else
                  {           
                      Loan loanItem;
                      loanItem = new Loan(bId, titFld,
                      authFld,Double.parseDouble(priFld));
                      model.addLoan(loanItem);
                      dlm.addElement(bId);
                      setClearTextFld();
                  }
              }
  
              else if (ae.getSource()== deleteButton)
              {
                  model.deleteLoan(model.getSelectedListIndex());
                  dlm.removeElementAt(model.getSelectedListIndex());
                  setClearTextFld();
              } 
  
              else if (ae.getSource()==viewDetailsButton)
              {   
                  loansView.buildGUI();
  
              }
  
          }
  
  
  
  
           /* This method clears the text field after the action Performed
            * method for the add and delete Buttons
            */
            public void setClearTextFld()
            {
                 loanIdFld.setText("");
                 lenderFld.setText("");
                 authorFld.setText("");
                 loanamountFld.setText("");
            }
  
  
  
  
  
            /* This value changed method gets the selected item in the JList
             * for performing the  
             */
            public void valueChanged(ListSelectionEvent e) 
            {
  
              listSelectionModel = (ListSelectionModel)e.getSource();
  
              int maxselectedListIndex = listSelectionModel.getMaxSelectionIndex();
              int minselectedListIndex = listSelectionModel.getMinSelectionIndex();
  
              System.out.println(selectedListIndex);  
  
              if (!listSelectionModel.isSelectionEmpty())
              {   
              for (int i = minselectedListIndex; i &lt;= maxselectedListIndex; i++) {
                  if (listSelectionModel.isSelectedIndex(i)) 
                  {  
                     selectedListIndex=i;
                     System.out.println("inside valueChanged. selectedListIndex");
                     System.out.println(selectedListIndex);
                     model.setSelectedListIndex(i);
                     Loan selectedLoan = model.getLoan(i);
                     System.out.println(selectedLoan.getTitle().toString());
                     System.out.println(selectedLoan.getId());
                     System.out.println(selectedLoan.getAuthor());
                     System.out.println(selectedLoan.getTitle());
                     System.out.println((selectedLoan.getPrice()));   
          //             lenderFld.setText(selectedLoan.getTitle().toString());
            //           authorFld.setText(selectedLoan.getAuthor().toString());
              //     loanamountFld.setText(Double.toString(selectedLoan.getPrice()));
  
  
                 loanIdFld.setText("1234");
                 lenderFld.setText("Test LoaN NAME");
                 authorFld.setText("Test lender");
                 loanamountFld.setText("Test loan amount");
  
  
                  }
              }
              }
  
            }
  
            }
  </code></pre>
  
  <p>What I want is when someone clicks on the GridBagLayout's loanid instances, details about the loan are displayed. I can see that valueChanged() is called as "inside valueChanged. selectedListIndex" is printed but loanIdFld.setText("1234") does not update the LoadId text field with 1234. 1234 is a random number I inserted to determine if something can be displayed but that also is not shown. Some functions are not defined here, but there is no syntax error.  </p>