DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    3

    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:
    Code:
    JLabel jLabel1 = null;
    jLabel1.setText("text");
    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?

    Thanks

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

  3. #3
    Join Date
    Jul 2007
    Posts
    3
    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
    Posts
    3
    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

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links