DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2007

    Edit JPanel Text During Runtime...from another class

    I am very new to Java and am having trouble changing text at runtime in a JLabel. My main class is set up to handle the computation and displays the UI frame when necessary. I am reading in data real-time so i need to be able to constantly change the label in my frame as the data changes.

    I have been testing to see if I could make the runtime changes by putting the code directly into the UIFrame's main. I created the label using the Netbeans design editor and then used this code:
    JLabel jLabel1 = null;
    which gave me no errors, but had no effect on the label. How do I link my code-created instance with the Netbeans-created label?

    Then, if I can get that to work, how do I access that same label from my (seperate) Main class?


  2. #2
    Join Date
    Dec 2004
    San Bernardino County, California
    how are you re-painting the label when you update the content?

  3. #3
    Join Date
    Jul 2007
    I have tried validate() and repaint() but neither of them work.

    Basically, my frame shows up when I run. If I create the label before running with NetBeans, it's there but it won't change. If I try to create a new label at runtime, it never shows up.

    I really think my problem is related to how my instance is(not) linked to the preexisting label. Of course, I am very new so I'm open to all suggestions.

  4. #4
    Join Date
    Jul 2007
    In case anybody else has a similar problem, I discovered that I couldn't see my label was because it wasn't on the root pane. I had to add a panel and set the default pane.

Similar Threads

  1. Byte Problems
    By Rmstn1580 in forum Java
    Replies: 2
    Last Post: 01-07-2007, 11:54 PM
  2. Problem with inner class
    By IronJack in forum Java
    Replies: 12
    Last Post: 08-08-2006, 06:52 PM
  3. Replies: 2
    Last Post: 08-06-2006, 01:49 PM
  4. Importing text file using schema.ini
    By Kevin in forum VB Classic
    Replies: 3
    Last Post: 12-05-2005, 06:25 PM
  5. Runtime error 'class not registered'....
    By ahamed in forum VB Classic
    Replies: 1
    Last Post: 06-12-2002, 10:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.