title: how to add items to a list box from another class in netbeans
body: <p>I would like to add elements to a list box on a jframe, from a different class however it doesn't seem to work no matter what i try... i do not get an error or any feedback on whats wrong with this...  but heres the layout i have,  the listbox is using DefaultListModel lm2</p>
  
  <p>I know how to add elements to a jList in the jframe class, but for some reason i am unable to add elments from another class even when adding this inside the jframe class:</p>
  
  <pre><code>  public void log(String str) {
        lm2.addElement(str);
      }
  </code></pre>
  
  <p>and on my "other class"</p>
  
  <pre><code>  frmMain doit = new frmMain();
  
    doit.log("add to list box");
  </code></pre>
  
  #
  
  <p>More details add- --- ></p>
  
  #
  
  <p>I have 3 classes and here they all are:</p>
  
  <p>frmMain.class  </p>
  
  <pre><code>  // jFrame class which builds the jframe (from jframe template)
      public class frmMain extends javax.swing.JFrame {
  
          /** Creates new form frmMain */
          public frmMain() {
              initComponents();
          }
  
  
  
          public void log(String str) {
            lm2.addElement(str);
          }
  
  
  
           public DefaultListModel lm2 = new DefaultListModel();
      }
  </code></pre>
  
  <p>RequestInfo.class</p>
  
  <pre><code>// RequestInfo.class, which is trying to add an item to the 
  // jlist but it doesn't add anything or error
  
  public class RequestInfo {
  
    public void ProcessReturnedInfo(String sData, boolean bWithLabel) {
  
  
              frmMain fm = new frmMain();
              fm.log("test test");
  
  
  
  }
  </code></pre>
  
  <p>RS232Example.class</p>
  
  <pre><code>     // My main class which sets the jFrame to visible
    public class RS232Example {
        public static void main(String[] args) throws Exception {
  
  
          frmMain form = new frmMain();
          form.setVisible(true);
  
      }
  
    }
  </code></pre>
  
  <p>I understand maybe i need to set form to visible on the RequestInfo.class, however i can't do this, because it will continuously open the form multiple times, because this class method is called multiple times from an event... </p>