Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Updating a text area from a JtextField! HELP

  1. #1
    Member
    Join Date
    Jan 2012
    Posts
    107
    My Mood
    Grumpy
    Thanks
    6
    Thanked 2 Times in 1 Post

    Exclamation Updating a text area from a JtextField! HELP

    			usernamelabel = new JLabel ("Username: ");
    			add(usernamelabel);
    			username = new JTextField ("Guest", 10);
    			add(username);


    			users = new TextArea(username.getText(), 15,20, TextArea.SCROLLBARS_VERTICAL_ONLY);
    			users.setEditable(false);
    			add(users);

    The TextArea - users Dosent update when i change the Username, can someone help me?


    http://prntscr.com/5j7qf <-PICTURE


  2. #2
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Re: Updating a text area from a JtextField! HELP

    users = new TextArea(username.getText(), 15,20, TextArea.SCROLLBARS_VERTICAL_ONLY);
    When you use username.getText() in the constructor, the JTextArea's initial text is set to the value currently in the username JTextField. However, nothing in your program is telling users's text to update if username's text is changed. You need to write some code that does that. I suggest looking at a DocumentListener.
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.

Similar Threads

  1. Text file to text area and Radiobuttons?
    By donaldmax in forum What's Wrong With My Code?
    Replies: 9
    Last Post: May 27th, 2011, 04:45 AM
  2. Display in a text area
    By susieferrari in forum Java Theory & Questions
    Replies: 21
    Last Post: March 22nd, 2011, 09:56 AM
  3. JTextField getting text values
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 18th, 2010, 05:41 PM
  4. Jigloo help to produce a text area which only scrolls down
    By rtumatt in forum AWT / Java Swing
    Replies: 0
    Last Post: February 2nd, 2010, 06:09 PM
  5. Problem in implementing mortgage calculator
    By American Raptor in forum AWT / Java Swing
    Replies: 1
    Last Post: April 1st, 2009, 02:09 PM