Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8182951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:00:50+00:00 2026-06-07T01:00:50+00:00

I’m new to Java programming and am facing a (most likely) easy problem that

  • 0

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.

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).

In the Collision.java main method, I am doing the following:

  public static void main (String[] args) {

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


    new SimulatorGUI().setVisible(true);
    CollisionPanel update = new CollisionPanel();
    update.updatepanel();

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:

public void updatepanel(){
    System.out.println ("debug");
    jTextArea1.setText("update\n");
}

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:

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

This does the trick! I’ve searched and tried different things but can’t seem to understand why this won’t work.

Thanks in advance for your help, hope I’ve made the problem clear!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:00:54+00:00Added an answer on June 7, 2026 at 1:00 am

    Okay I think I’ve eventually got the problem, and it is because of the IDE, you see in your main method you initiate a new CollisionPanel, which is wrong, netbeans has already added and initiated that panel in the SimulatorGUI, so now what you need to do is add a get method in the SimulatorGUI to get the initiated panel, then call the update method on that panel.

    So add this to SimulatorGUI:

    public CollisionPanel getCollisionPanel1() {
        return collisionPanel1;
    }
    

    replace your old updatePanel() method with:

     void updatepanel(String str) {
                System.out.println ("debug");
                jTextArea1.setText(str);
             //   jTextArea1.revalidate();
                jLabel1.setText("test");
            }
    

    after that change your main too look like this:

                SimulatorGUI simulatorGUI = new SimulatorGUI();
                simulatorGUI.setVisible(true);
                CollisionPanel cp=simulatorGUI.getCollisionPanel1();
                cp.updatepanel("Hi");
    

    and dont forget to remove the old updatePanel() method call from your CollisionPanel constructor, because now you can simply call cp.updatePanel("text here"); in your SimulatorGUI class instead of calling it only in the constructor.

    I hope this is easy to grasp, if you’re unsure let me know

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.