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:
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?
JLabel jLabel1 = null;
Then, if I can get that to work, how do I access that same label from my (seperate) Main class?
how are you re-painting the label when you update the content?
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.
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.
By Rmstn1580 in forum Java
Last Post: 01-08-2007, 12:54 AM
By IronJack in forum Java
Last Post: 08-08-2006, 07:52 PM
By AxWielder in forum Java
Last Post: 08-06-2006, 02:49 PM
By Kevin in forum VB Classic
Last Post: 12-05-2005, 07:25 PM
By ahamed in forum VB Classic
Last Post: 06-12-2002, 11:18 AM
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