Results 1 to 2 of 2

Thread: [RESOLVED] NetBeans > JFrame > control

  1. #1

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Resolved [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.

    BOFH Now, BOFH Past, Information on duplicates

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

  2. #2

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    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.

    BOFH Now, BOFH Past, Information on duplicates

    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
  •  



Click Here to Expand Forum to Full Width