• Post Reply Bookmark Topic Watch Topic
  • New Topic

Not sure where I went wrong, Jtextarea updates  RSS feed

 
Chuck Barnes
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i want to send updates to a text area to display to the user. I created a swing GUI with a text area to display the process of the application. I added some function to accept the updates.



If I test the new static functions from within the GUI class it displays correctly.
But any reference to the functions outside in a different class do not display the text.



I don't get any errors when it hits the code so I don't what is wrong or how to go about fixing it.

Any help would be great.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am thinking, the LogTextArea in your method is not what you think it is. Can you show us where and how you initialized that variable?
Just create a SSCCE * version of your code
* Do take out time to click the link to find out what SSCCE really means.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why are you calling an int “text”? Identifiers are supposed to make the code easier to understand . . .
 
Chuck Barnes
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:I am thinking, the LogTextArea in your method is not what you think it is. Can you show us where and how you initialized that variable?
Just create a SSCCE * version of your code
* Do take out time to click the link to find out what SSCCE really means.




That is the auto generated code from netbeans gui designer.

It will take me a little time to create that sscce



this is the code from inside the MenuUI class that works correctly. if that helps

 
Chuck Barnes
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:And why are you calling an int “text”? Identifiers are supposed to make the code easier to understand . . .


Yes that would be something like "percentComplete" instead of text
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chuck Barnes wrote: . . .

That is the auto generated code from netbeans gui designer. . . .
You might be making life difficult for yourself by using NetBeans at too early a stage in your career.
 
Chuck Barnes
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well poo.
The SSCCE version works...
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That’s probably because you have extricated it from NetBeans’ clutches
 
Chuck Barnes
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Chuck Barnes wrote: . . .

That is the auto generated code from netbeans gui designer. . . .
You might be making life difficult for yourself by using NetBeans at too early a stage in your career.


How so? what would you recommend?
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have got NetBeans writing the code for you. That is very useful if you are experienced, already knowing how to set sizes, locations, etc., of components. But it isn’t much use if you are still learning about components, because you never see the works.
Either
  • Don’t tell NetBeans you are writing a GUI; let it think you are writing an ordinary class, or
  • Write it by hand.
  •  
    Chuck Barnes
    Ranch Hand
    Posts: 37
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Chuck Barnes wrote:Well poo.
    The SSCCE version works...


    So now the problem is what part of what i removed is the issue. the sscce version is the bare minimum and it doesn't seem very likely to start piecing bits back in as it quickly starts to require 90% of the code I removed.

    I can post the ssccee version if it will help.
     
    Chuck Barnes
    Ranch Hand
    Posts: 37
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Campbell Ritchie wrote:You have got NetBeans writing the code for you. That is very useful if you are experienced, already knowing how to set sizes, locations, etc., of components. But it isn’t much use if you are still learning about components, because you never see the works.
    Either
  • Don’t tell NetBeans you are writing a GUI; let it think you are writing an ordinary class, or
  • Write it by hand.


  • I would agree with you but not in this case.

    in the sscce the GUI class is copied word for word, nothing was removed in that class. I also ran the sscce version with a 'jframe form' class and a reg java class file as far as netbeans was concerned. and both ways worked as expected.

    So at this point i don't think the issue is with the code inside the menuui.class
     
    Chuck Barnes
    Ranch Hand
    Posts: 37
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I think I found the problem.

    I placed a line in the original project before any processing would occur AFTER USER input. so they select the process to run and it displays the message (woot)
    BUT none of the following progress messages displays.

    Which tells me that the thread is not updating the GUI.

    I guess I need one thread to process the work and leave the main thread to handle the gui

    Does that make sense as the cause?

    if so, can someone point me in the direction of a good threading tutorial? I've done threading in .net but not java.
     
    Paul Clapham
    Sheriff
    Posts: 22819
    43
    Eclipse IDE Firefox Browser MySQL Database
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Google keywords: swing threading tutorial. Look for Oracle's "Concurrency in Swing" in the list you get.
     
    Chuck Barnes
    Ranch Hand
    Posts: 37
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Paul Clapham wrote:Google keywords: swing threading tutorial. Look for Oracle's "Concurrency in Swing" in the list you get.


    That thread link worked. Its updating as expected. Thanks all
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!