-
Jan 4th, 2017, 07:37 AM
#1
Thread Starter
Don't Panic!
[RESOLVED] NetBeans > JFrame > control
Hi
I am getting to use the NetBeans and Java proper (instead of the framework on a server).
However, this poses different problems. First one I have is this:
I have created a form using NetBeans.
In the code of the form I want to update a labels text with something else.
I see that there is already a variable that NetBeans added and uses to add the JLabel to the form.
When I try to use it though, I get a NullPointerException. Looks like it has lost the reference it previously used to create the JLabel.
So I'm doing it wrong, I know this. So how do I change the text?
Java code : I call this after the form is visible.
Code:
public void debugChangeLabels(){
//debug - labels
if( sessionApp == null ) { sessionApp = "Session Nada"; }
if( usuario == null ){ usuario = "usr nada"; }
jlblsess.setText("hhh");
//jlblusr.setText(sessionApp);
//jlblsess.setText(""+usuario);
}
Note: I cannot change the code generated for the form as it will be overwritten if I move anything on the form in design...
jlblusr is a JLabel it already used to addComponent to the form.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Mar 7th, 2017, 03:46 PM
#2
Thread Starter
Don't Panic!
Re: NetBeans > JFrame > control
Turns out that the form runs in a thread... so the code was trying to read a control that hadnt been created yet. Solved it (somehow). Think I moved the code or pointer was set when the form was finally created.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|