Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Norm

Thread: How to refresh JTextArea?

  1. #1
    Nozz is offline Member
    Join Date
    Apr 2014
    Posts
    49
    Rep Power
    0

    Default How to refresh JTextArea?

    I have little problem.
    I created this JTextArea with some text in it. And it also has few variables.
    Sth like that:
    Java Code:
    protected JTextArea textLog;
    
    textLog = new JTextArea();
    textLog.append("test: "+variable);
    And now while I use button that changes variable value, in textLog variable still shows old value.
    Tried to use remove(textLog); textLog.validate(); etc(remove, validate, revalidate, add, repaint), because it works fine with JButtons, but still, in textLog variable gives me old value.

    And please, give me simply answer to question, like "you should use somethingvalidate(); while clickin button and it will works", not some shit for 3032 lines with 99% of code that I don't need to do what I want.
    Last edited by Nozz; 04-21-2014 at 10:25 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: How to refresh JTextArea?

    If you want to change the contents of the textarea use its set method.
    Nozz likes this.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Nozz is offline Member
    Join Date
    Apr 2014
    Posts
    49
    Rep Power
    0

    Default Re: How to refresh JTextArea?

    Just needed setText and move whole text String variable declaration, because it wasn't changing even while value of inside variable was different...
    Anyway, thanks for "set". I was reading documentation for like 30 mins, just methods part of JTextArea and couldn't find it...

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: How to refresh JTextArea?

    Quote Originally Posted by Nozz View Post
    And please, give me simply answer to question... not some s**t for 3032 lines with 99% of code that I don't need to do what I want.
    First, someone seeking help is in no position to dictate the nature of that help. Second, most folks on this forum would not spoon feed you a solution anyway. And lastly, you can be banned from the forum for using profanity so please don't do it in the future.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    Nozz is offline Member
    Join Date
    Apr 2014
    Posts
    49
    Rep Power
    0

    Default Re: How to refresh JTextArea?

    Dictate?
    Where did I dictated anything? I just pleased for something simply...
    I'm just tired of taking like 100 line of code while I only need 1 line in right place. It happened to me few times. For example I just needed to validate(); in two places, and someone told me that I need to rebuild whole project and add like 120 lines to make something happen...
    Its just like, "oh you are out of gas? here, i give you gas company, which won't make your car run by now, but well, you can have gas later"... Aaaaand, I'm dead. Because I'm out of gas in middle of nowhere...

  6. #6
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    272
    Rep Power
    7

    Default Re: How to refresh JTextArea?

    Quote Originally Posted by Nozz View Post
    Dictate?
    Where did I dictated anything? I just pleased for something simply...
    I'm just tired of taking like 100 line of code while I only need 1 line in right place. It happened to me few times. For example I just needed to validate(); in two places, and someone told me that I need to rebuild whole project and add like 120 lines to make something happen...
    Its just like, "oh you are out of gas? here, i give you gas company, which won't make your car run by now, but well, you can have gas later"... Aaaaand, I'm dead. Because I'm out of gas in middle of nowhere...
    This event to have happened here is highly doubtful. Most of the times the responses do not involve source code and they never give packaged solutions of many lines.

Similar Threads

  1. Refresh A JList
    By anthropamorphic in forum New To Java
    Replies: 7
    Last Post: 09-11-2011, 06:59 PM
  2. refresh a jframe
    By dalu in forum New To Java
    Replies: 2
    Last Post: 08-22-2011, 01:41 PM
  3. refresh help
    By silverspoon34 in forum New To Java
    Replies: 6
    Last Post: 03-29-2011, 03:03 AM
  4. JTextArea on PopUp -JTextArea isn't editable
    By Richy76 in forum AWT / Swing
    Replies: 3
    Last Post: 02-01-2010, 08:51 PM
  5. Refresh Button?
    By jls7168 in forum New To Java
    Replies: 2
    Last Post: 02-06-2009, 07:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •