Results 1 to 6 of 6
  1. #1
    dhany is offline Member
    Join Date
    Aug 2011
    Posts
    6
    Rep Power
    0

    Question Carriage Return Mark for JTextArea

    Assume i have JTextArea contained With long Wraped Text, This texts are contained with some Paragraph, Also I have String variable to hold this JTextArea content gathered by getText(), but when i write this String to file and reopen it weird thing happen. the text has no paragraph, all wraped as if it has no Carriage Return mark. can anyone show the way to fix this ?
    Java Code:
    JTextArea myTextArea = new JTextArea();
    String myString = myTextArea.getText();

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,253
    Rep Power
    25

    Default Re: Carriage Return Mark for JTextArea

    Does the textarea wrap its contents without any lineend characters?
    Does your textarea's contents have lineend characters in it that are not being returned by the getText() method?

    all wraped as if it has no Carriage Return mark.
    Do you mean that the text in the file was all on one line? IE no lineends.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Carriage Return Mark for JTextArea

    but when i write this String to file and reopen it weird thing happen.
    Write to file, how? Reopen, how?

    Recommended reading: How To Ask Questions The Smart Way

    db

  4. #4
    dhany is offline Member
    Join Date
    Aug 2011
    Posts
    6
    Rep Power
    0

    Default Re: Carriage Return Mark for JTextArea

    Does the textarea wrap its contents without any lineend characters?
    yes it does have a method to make it content wraped
    Does your textarea's contents have lineend characters in it that are not being returned by the getText() method?
    Java Code:
    String myString = jTextArea[0].getText()+jTextArea[1].getText()+jTextArea[2].getText();
    //call my function to write into the file
    writeMyFile(mystring)
    but when i open this created file with notepad , its only has 1 very long line. aka no paragraph no new lines

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,253
    Rep Power
    25

    Default Re: Carriage Return Mark for JTextArea

    what happens if you open the file in another editor? Not all editors process lineend/carriage return the same way.

    In Notepad: Are there small squares where there would be lineend/carriage returns?
    Last edited by Norm; 09-13-2011 at 05:01 PM.

  6. #6
    dhany is offline Member
    Join Date
    Aug 2011
    Posts
    6
    Rep Power
    0

    Default Re: Carriage Return Mark for JTextArea

    Quote Originally Posted by DarrylBurke View Post
    Write to file, how? Reopen, how?

    Recommended reading: How To Ask Questions The Smart Way

    db
    thanks for your advise, i'll remember that.

Similar Threads

  1. Disable enter/return key in JTextArea
    By applewood13 in forum AWT / Swing
    Replies: 3
    Last Post: 05-29-2011, 05:59 PM
  2. Replies: 4
    Last Post: 05-06-2011, 07:04 PM
  3. Carriage Returns in JTEXTAREA
    By AJArmstron@aol.com in forum Advanced Java
    Replies: 8
    Last Post: 04-17-2010, 07:34 PM
  4. Waiting for a carriage return
    By Ebodee in forum New To Java
    Replies: 1
    Last Post: 02-12-2010, 03:46 AM
  5. New line or Carriage Return through FileWriter
    By johnt in forum New To Java
    Replies: 2
    Last Post: 05-20-2007, 09:13 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
  •