Converting a multi-line text to one-line

Hi
I have a problem with a multi-line text, to be converted to one line, which I take from a JEditorPane.
I tried several things but it is still multi line
// the text is taken from JEditorPane
String str = jeditorPane.getText();
// replace "\n" with " "
str.replaceAll("\\n", " ");or
// the text is taken from JEditorPane
String str = jeditorPane.getText();
Scanner s = new Scanner(str);
String line;
String completeText="";
while( ( line = str.nextLine() ) != null  ){
      completeText += line + " ";
}In the fist code, it replaces all the "\n"'s with a space but it is still multi-line
in the second one, it doesn't change anything
So, what is wrong with these codes?
p.s. In the second code there (may) be a little mistake causing compile time error, please ignore that, my problem is with the logic of the code
thanks

How do you know that the string is still multi-line after you have executed replaceAll? Have you tried to also remove all \r in the text?
Kaj

Similar Messages

  • How do I create a multi-line text box?

    I have a PDF that was tradionally printed and filled out by hand, and am trying to convert to an e-version.
    Everything is working great but I can't figure out how to make this one thing work. For example I have a section like this:
    More Info: _______________
    How can I make it so when one starts typing in the "More Info" section, their response continues from the 1st line to the 2nd, to the 3rd, etc.?

    You can set a text field to be multi-line and tick off the option to scroll
    long text to have it automatically wrap, but you'll have a problem with the
    first partial line, since form fields can only be rectangular. Another
    problem might be the lines themselves, since you'll have to use a font size
    that will fit them exactly, or it will look odd. I would suggest getting
    rid of those lines altogether. They are not needed when filling in the form
    electronically. It's a relic from printed out forms where people had to
    hand-write their answers.

  • Permanently save line spacing in a multi-line text field

    Me: Adobe Acrobat 8 Pro, Windows Vista
    (I think the people who will be using the form have Reader 7 on Windows)
    I work in a doctors' clinic, and we use phone message sheets to document conversations between the patients/us/nurses/doctors, and I scanned the form and made it into a fillable PDF for our secretaries to fill out more quickly. The "message" area has pre-printed lines on it, and the multi-line text field I placed there needs to match up to the lines. I used the Rich Text Formatting options to set it to "Exactly 24 Points," but I can't get it to KEEP the formatting permanently. The only way I could get it to save the formatting in that field was to put a space in it and then save it, and then give that to the 2 phone secretaries. It works perfectly the first time, but instead of just closing/re-opening the file to start a new message, one of the secretaries highlights everything in the "message" field and deletes it... which deletes the line spacing formatting. I've told her
    b numerous
    times to leave that starting space in the field, but she "forgets" so all of her messages look messed up. So is there a way to force that line spacing
    b PERMANENTLY
    ???? Here's a shrunken screenshot of the field -- I wish I could just erase the lines altogether so the spacing wouldn't matter, but the secretaries type/print the message out, then the nurses/docs write on the page with pen so the lines have to stay. http://img187.imageshack.us/my.php?image=notepreviewph8.jpg
    Thanks!

    You can set the font size of the text. Then play with the underlines in the original document to match the needs of the font that is used. Print to a new PDF and then use replace pages to put the new page into the form without changing the form fields. I was able to do this with a word processing document by adding underlining in the document with 12 pt and setting the font to 12 pt in the text field. You can play with the font, the border of the field, and the underlining in the original document to get the desired result. Is this optimal, probably not. However it does the job.

  • How to determine the length of a line of text in a multi line text control

    I am working on a simple widget to compare two snippets of text.  The string controls are side by side with a colum of square bools in between
    the two string controls.
    The Bools line up with the lines of text in each string control.  The Bools are used as a quick indicator that at that line point there is a difference
    between the two string controls.
     There is a slider that allows the user to scroll up and down,  the slider scrolls both string controls simutaneously.
    As the string controls are scrolled I will be comparing the left and right lines of text and reflecting the match status in the Bool Colum.
    The reason I need to know the length of the line of text is so each line can be compared against one another.  It is not as simple as counting the
    col width of the string control and parsing the text because if there is a line return the text will word wrap before before it extends all the way accross the string control, which will cause parsing discrepencies.
    Any suggestions on obtaining the multi line string control text character length would be much appreciated.
    Best Regards
    Tim C. 
    1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!

    Front panel of widget....
    1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!
    Attachments:
    One.vi ‏27 KB

  • How do I center a text field when input can be single or multi-line?

    I'm creating a form in Adobe Acrobat Pro XI and have almost everything the way I want it.  One of my last problems is trying to get a text in a text field centered.  The input is sometimes a single line and sometimes multi-line.  If I set it up so the multi-line entries are centered, then the single line looks off ... and vice versa.  Is there any way to have the text automatically centered in the text field regardless of whether it's single or multi-line?

    Unfortunately, there's no way to set up a field so that the text is guaranteed to be vertically centered in both cases. If you set it up so that rich text formatting is enabled, it's possible for a user to vertically center, but it's not something you can preconfigure so that it will remain in effect when the field is cleared. For a user to do this, with the focus set to the field they'd have to display the Properties toolbar (Ctrl+E), click the "More..." > Paragraph > Alignment > Text Middle [button]

  • Why is the multi-line option not allowed in my text fields? Acrobat X Pro

    I have created a form in which I wish to make mulit-line fields. To create the original fields, I used auto field detect, then copied and pasted them to repeat in a chart. None of these fields allow me to select the multi-line and scroll text options I need (including the first auto-detected ones). When I draw a new field, it allows me to apply multi-line and scroll text. Any idea whay these first fields arent allowing the same? thanks!

    ah! found it - the option for Comb of Characters was checked, thus greying out the other options. Thanks anyway!

  • Displaying Multi Line Text

    Hi,
    I am having issues in displaying multi line text on a Text Item. Basically there is data in the database column DetailText which is stored like this with carriage returns :
    If I look at the column in Toad it is formatted with all the carriage returns correctly eg.
    Hello
    World
    When I display this in my StaticStyled Item it displays like "Hello World" in one line. I want to be able to display it as it is with the carriage return on 2 seperate lines.
    I have looked in this forum and one search 2 places and one suggestion was to use RawText Item type. I have tried changing the Item Type to Raw Text and FormattedText but it doesn't make any difference. The lines are still displayed horizontally instead of vertically. Another place I saw was to use OAHTMLWebBean but doesn't show how I can do this.
    This should be simple enough but I have searched the DevGuide and this forum and couldn't figure out the solution. Any help would be appreciated.
    Thanks

    Hi,
    I tried to do it in different way. What i did is I have created a item of type formattted text and set its text like:--
    <html>User authentication failed. <br*> Cause: Invalid password.</html> --remove *
    So I am able to see the prompt like :-
    User authentication failed.
    Cause: Invalid password.
    Hope this helps you...
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Saving an array of multi-line text cells in a format that can be read in later

    I can create an array of multi-line text entries that my program can then pick cells and compile them into a list of text.
    I would like to be able to Save the array as a file, then change my program to read in the file.
    If I use the Save Spreadsheet file vi, the data is corrupted by the carriage returns within the cells and the data read in is messed up.
    Can someone recommend a way to save the array that preserves the carriage returns?

    As far as I know, this cannot be done automatically with the basic VIs from the palletes.  I would convert the [LF] into another group of characters (likely "\n") and then save the text array to a CSV file.  Don't forget to escape any good "\" string with an extra "\.  Regular expressions would work really well:
    Just make sure you parse your entire array of strings with this.
    Olivier
    Attachments:
    SaveToCSV_WithMultiLine.vi ‏9 KB

  • Multi line tool tip / OTR text

    Hello experts,
    do you know a possibility to apply a multi-line tool tip to a ui element in abap web dynpro ?
    The OTR compresses multiple lines to one long line...
    Thanks in advance.

    Hi,
    I realize this is a very old thread, but in case others, like myself, finds it, here's a simple fix for this. In the OTR text add a constant for the desired linefeed - for example "\n":
    Alias ZPACKAGE/ALIAS: Line 1\nLine 2
    * Generate tooltip text
    DATA:
      lo_el_ui TYPE REF TO if_wd_context_element,
      lv_tooltip TYPE string.
    lv_tooltip = cl_wd_utilities=>get_otr_text_by_alias( 'ZPACKAGE/ALIAS' ).
    REPLACE ALL OCCURRENCES OF '\n' IN lv_tooltip WITH cl_abap_char_utilities=>newline.
    lo_el_ui->set_attribute( name = 'TOOLTIP' value = lv_tooltip ).
    The same technique can be used for tabulators (using constant
    cl_abap_char_utilities=>horizontal_tab), however, there's no guarantee how this will presented in the browser.
    Best regards,
    Jacob Laursen

  • Displaying a multi-line text block in an ALV grid cell

    Can I display a multi-line text block (i.e. a paragraph of text) in an ALV grid cell?
    If yes, what properties do I set in the Field Catalaog (I tried the style and that didnt seem to work)
    Thanks

    By default ALV Grid merges fields with same values vertically.
    Isn't that only when the column is part of the sort key? You also have to consider the user changing the sort sequence, which can make the text jumbled up. In one of my reports I have made the cell a hotspot and displayed the text in a popup. Of course you cannot print it.
    Cheers,
    Ramki.

  • Comments & multi-line text not showing up on summary report

    My multi-line answers and comments are not showing up on my summary report

    Hi;
    The summary report does not show the text based answers.  This isn't something FormsCentral supports.
    If this is an important feature for you, we do have a "Feature Request" form where you can vote on popular existing ideas or add a new one of your own:
    https://adobeformscentral.com/?f=XnF-KJVCovcEVQz9tZHYPQ
    Thanks,
    Josh

  • How do you display multi line text

    Hi
    How does one display multi line text? I would like to display address information on the screen so that the user can select it and copy/paste it into another application (ms word).
    I have the address information as separate columns (address1, address2, city, province, postal code) so I've changed the query on my view object to add it as address1 || chr(10) || address2 || chr(10) || city ....
    If I display it on the page as an output text, it all displays as one line (okay, the chr(10) thing did not work but that's beside the point).
    In general, is there a way to display multi line text? What component is suitable for this, if there is one?
    Thanks

    You can use normal outputText components in a panelGroupLayout (vertical layout) and add each attribute to it. The remove the labels or set the components to simple. You can then mark the data in the browser and use normal copy&paste to transfer the data.
    If you want to output longer text with line breaks you can use an outputText with escape=false and use the br html tag to generate a line break;
    <af:outputText escape="false"
    value="+++++++long<br>test<br> this is a long text in multiple lines" id="ot10" truncateAt="#{viewScope.ToggleBean.truncateLength}"/>Timo

  • Setting hotspot to multi line text

    In the AutoVue 2D(dwg) hotspot, one line text hotspot works well.
    but i can't setting hotspot keyword is separated in two lines.
    this keyword is founded when i find at Find Text dialog (Edit> Find Text menu)
    so i think must be hotspot will work.
    to set multi line hotspot, how do i set DEFINITION_REGEX.
    or if multi line hotspot is not supported, how do i modify dwg files to work hotspot.

    Hotspot handler is looking inside each text record. If the lines belong to different records this will not work.
    Try to set the regEx to any text (regEx=.*) and hover the mouse over the desired lines.
    If both lines are not highlighted, this means that they belong to different records
    Otherwise need to parse the selected lines and try to set the correct regEx.

  • How to display multi-lines text correctly (view only mode)

    Hi,
    I have a description field that includes multi-lines format, where the lines are being separated by
    characters: chr(10) and chr(13).
    When I’m using messageStyleText (or rawText) – I’m getting all the data in one line.
    Can you please recommend of an OAF item that will display the text correctly?
    Should I use another character as the line separator?
    Thanks in advance,
    Rona

    Hi Rona;
    rawText item supports HTML tags. so you can use br tag.
    Best Regards;
    GsrC.
    Message was edited by:
    GsrC

  • Text Multi-Line

    Hi All
    I have a five field on a canvas and in which one field has multi-line property true. when i find recod to update and navigate cursor in the record; on entering the curson in a field all the text is highlited and pressing the enter key I can move to the next item. when the cursor go in the multi-line text and same all the text is automatically selected and if any one press enter key so all the text is going erased. so is there any property that i can set that on entering into that item the text shold not be highlited ?
    thanks in advance

    it is buggy for ENTER key, but you may use TAB key.

Maybe you are looking for

  • How to create Table in a Table without a ViewLink for Master/Detail

    Hi, Can we create a Table within Table in OA Page without using a view link. Need a Master Detail records to be displayed but I can't use a ViewLink. Is it possible to have a Table within Table without using a ViewLink. As I have DetailVO with multip

  • [JS CS3] Page side when adding pages

    Hello all, I am using a script to remove oversets by adding pages with linked text frames to the end of the document. When I am done removing the oversets, I check to make sure the document ends on a left page; if not, I am using the code below to ad

  • Iphoto'08 (version 7.1.5)

    i have mac OS X version 10.7.5 (processor 2.16 GHz Intel Core 2 Duo), l would like to connect my iphoto'08 (version 7.1.5) to my icloud account. how do l do this?

  • Can't install kernel 24

    here is the output: [root@blue qax]# pacman -Syu :: Synchronizing package databases... core is up to date extra is up to date community is up to date :: Starting full system upgrade... warning: dnsutils: forcing upgrade to version 9.4.2-1 warning: fl

  • Install oracle management server

    hi for all please if you can help me when i tru to backup any datafile from oracle enterprice manager error message tell me i must to install oracle management server can you help me how to install it