Reference a method from a different Java file
<p>I'm new to Java programming and am facing a (most likely) easy problem that I don't seem to be able to get across nor understand.</p>

<p>I have three different java files, one where I create an interface (SimulatorGui.java), other where I am creating a panel to use on the jTabbedPanel created in the interface (CollisionPanel.java - CollisionPanel class) and a third one, where I run a code that will create the output needed (Collision.java - Colision class).</p>

<p>In the Collision.java main method, I am doing the following:</p>

<pre><code>  public static void main (String[] args) {

    //&lt;editor-fold defaultstate="collapsed" desc="Simulation start procedures"&gt;
    Tally statC = new Tally ("Statistics on collisions");
    Collision col = new Collision (100, 50);
    col.simulateRuns (100, new MRG32k3a(), statC);
    //&lt;/editor-fold&gt;


    new SimulatorGUI().setVisible(true);
    CollisionPanel update = new CollisionPanel();
    update.updatepanel();
</code></pre>

<p>The first block, will create the desired output. I then want to send that output to the updatepanel! I am not passing any arguments to the method as I am still trying to debug this. updatepanel method is created in the file CollisionPanel as following:</p>

<pre><code>public void updatepanel(){
    System.out.println ("debug");
    jTextArea1.setText("update\n");
}
</code></pre>

<p>What happens then is that when I run the Collision.java file it will output the "debug" text but won't set the text to the jTextArea1 (append doesn't work aswell). I then created a button to try and do so and in that case it works. In CollisionPanel.java:</p>

<pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    updatepanel();
}
</code></pre>

<p>This does the trick! I've searched and tried different things but can't seem to understand why this won't work.</p>

<p>Thanks in advance for your help, hope I've made the problem clear!</p>
