Results 1 to 3 of 3

Thread: JTextArea

  1. #1
    johnny157 is offline Member
    Join Date
    Mar 2011
    Rep Power

    Question JTextArea

    Hey guys I had a question about JTextArea. I'm making a simple program to be a restaurant menu and when I click on a button it displays the name and the price of the item in the text area and when I click a different button it'll replace the previous line and it doesn't keep on going to the next line. Is there a certain command that I need to add or anything for it to do that?

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Richmond, Virginia
    Blog Entries
    Rep Power


    did you try using setText()? You can design the button to set the text to be empty, and then add the item to the text area.

  3. #3
    johnny157 is offline Member
    Join Date
    Mar 2011
    Rep Power

    Lightbulb .append

    Actually I found out what the problem was haha the problem was actually setText because everytime I was going to write to the text area i was using .setText and what I didn't know was that setText itself erases what was there originally and then replaces it with whatever. The solution was to use .append and that just goes onto the next line and doesn't erase what was there

Similar Threads

  1. Using JTextArea
    By tnixon22 in forum New To Java
    Replies: 10
    Last Post: 01-23-2011, 08:01 PM
  2. JTextArea
    By larry_d1990 in forum Advanced Java
    Replies: 4
    Last Post: 01-11-2011, 06:44 PM
  3. JTextArea
    By weikang in forum AWT / Swing
    Replies: 1
    Last Post: 12-01-2010, 05:51 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. About JTEXTAREA
    By makpandian in forum AWT / Swing
    Replies: 4
    Last Post: 03-19-2009, 07:53 AM

Posting Permissions

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