CR duplication when Copy/Pasting text from a JTextArea

I have a typical scenario of having text in a JTextArea. When I select some of that text and try to paste it either to an external text editor or even in the same JTextArea, I am getting extra line spaces in the screen.
For example, if I have the following text:
<a id=1>
   <b/>
</a>When I copy paste it, I get:
<a id=1>
   <b/>
</a>When I looked to see what characters were being used for the CR, I see "\r\n". This is the standard line.seperator for Windows OS which is fine. When I save this text to a file using the Java I/O libraries, it is fine (no extra lines). But when copy/pasting it prints extra lines.
Has anyone had similar problems?

Has anyone had similar problems? No. How are you doing the copy/paste? Did you write your own routines or are you using the default Actions. By default, when a Document is loaded it will convert the "\r\n" end of line string to "\n" and store the single character in the Document. When you use the getText(..) method the enod of line string will be expanded to "\r\n" on a Windows system, but this should not happen in a copy/paste operation. How do you add data to your text area?
This section from the Swing tutorial on "Text Component Features" has a working example of using copy/paste:
http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html

Similar Messages

  • Freeze when copy paste text from word to Indesign CC

    Hi,
    I have a problem when working with indesign CC. When i'm copying text from word to Indesign, after a while my windows system freezes. Only Indesign works. Windows and word are frozen. After a while (several minutes) the system works agian.
    This problem occurs sinc I have Indesign CC.
    Windows 8, indesign CC, Word 2013
    I hope someone has a solution.
    Ragards Bas

    It's the PDF.
    Usually, you can copy text out of a PDF, but there is no guarantee *at all*. Older software used to take shortcuts to subset fonts: first character it encountered got coded as #1, the next as #2, etc. etc. If you do a search & replace of each of the nonsense characters, you'll slowly see the original text appearing (thst's not as simple as it sounds, though).
    A similar "problem" is that sometimes spaces don't get copied (there is no need for a "Space Character" in a PDF), and that you cannot copy contiguous lines of text as a single paragraph. All of it is because a PDF is not intended nor designed to be re-used after creation.
    If you really need this text and don't want to type it in, try to get hold of the original file.

  • Can't shown chinese text when copy & paste data from server to Outlook, Word & notepad, etc.( Office 2013)

    Can't shown chinese text when copy & paste data from server to Outlook, Word & notepad, etc.( Office 2013)

    Hi
    As per the information and details provided by you, when you copy & paste a data from server to Outlook, word, notepad, then you do not receive the Chinese text.
    For Outlook, please follow these steps: -
    Close and reopen Outlook in your western locale (or switch the windows system to your Western locale if you changed that),
    Manually change the message from Western to Chinese encoding, which you can do in all versions up to Outlook 2007.
    If you want to stay in your Chinese locale in Outlook 2007, then:
    After you hit reply, go to the Option tab > More Options.
    In the Encoding drop-down menu, select the Chinese encoding you are working in (Not the encoding used by the person who will receive the message)
    Note:
    To set the Chinese locale in all versions up to 2007 the controls are under.
    Tools > Options. In Outlook 2010 File tab > Options > Advanced > International options.
    Unicode (UTF-8)
    is a good setting for multilingual users.
    Check the
    Auto select 2007)/ Automatically select (2010) encoding box.
    I hope this information will be helpful for you.
    Thanks and regards
    Shweta@G 

  • How can I copy/paste text from one page to another?

    I feel like I am taking crazy pills... is there really no way to copy a text box (or group) from one page to another while creating books in Aperture 3?  Lets say I have my entire book laid out and I want to add one paragraph at the end on one page which will push text and photos down a half page or so... in most programs for the last decade or so they added really cool functionality... cut/paste...  It seems like the apple developers are aware of it because they are in the context menus but they don't work on text, only photo boxes.  Additionally, you can copy/paste text but it erases all formatting.
    Seriously, am I missing something?  I have trouble believing that they can't include this function.
    Anyone else have this issue?

    Update... it seems to only happen with text boxes which I create.  So when I try an existing theme I can cut/copy/paste just fine, but in that same theme if you edit the layout and add a new text box, I can't copy paste it anywhere... the options are in the menu but nothing happens.
    Thoughts? Solutions?
    I am running 3.4.3 on a MacBook Pro OS X 10.8.3

  • Problems copy & paste text from PDF to InDesign CS5

    Hey guys
    Today, I tried copying and pasting text from a PDF I received from my client, into a InDesign CS5 doc, and the text came out was just random numbers and punctuations.
    I've tried exporting Word / RTF & TXT file from the PDF and yet they still come out random. I'm not sure if it's just how the PDF was made, or there is something wrong with my CS5.
    I'm on Snow Leopard, CS5 Premium, Acrobat Pro 9 & also Acrobat Reader X.
    Any ideas why?

    It's the PDF.
    Usually, you can copy text out of a PDF, but there is no guarantee *at all*. Older software used to take shortcuts to subset fonts: first character it encountered got coded as #1, the next as #2, etc. etc. If you do a search & replace of each of the nonsense characters, you'll slowly see the original text appearing (thst's not as simple as it sounds, though).
    A similar "problem" is that sometimes spaces don't get copied (there is no need for a "Space Character" in a PDF), and that you cannot copy contiguous lines of text as a single paragraph. All of it is because a PDF is not intended nor designed to be re-used after creation.
    If you really need this text and don't want to type it in, try to get hold of the original file.

  • Copy/paste text from Word doc or PDF to Robohelp

    Bolded words, indentions, paragraphs, line spacing, font, and
    text size amongst other things are lost when I do a simple
    copy/paste... Any way to relieve this?
    Thanks

    Hi
    I'd like to answer this in a slightly different way..
    It's a good idea to format anything you paste into RH in RH
    using paragraph styles etc. Hardcoded formatting won't be under
    stylesheet control which is very bad news.
    In fact I generally paste stuff from a word doc into notepad
    first to remove any formatting soI have "clean" text to begin with.
    That way you ensure consistency when styles are updated etc
    as well maintaining consistency with what's already there.

  • Copy/Paste Text from Word

    I've written a seminar on Word (Greek & English). I want
    this text on Director.
    When I copy the Word text and paste it on Director (on a text
    field) it changes the fonts.
    The problem is that, although I change the fonts on the whole
    text (to "Times New Roman Greek"), the english words sometimes look
    strange. So, I have to mark every english word and change its fonts
    from "Times New Roman Greek" to Times New Roman. As you see, it's a
    very time-consuming process and very exhausting. Is there an easier
    way doing this?

    download and extract to your director xtras folder:
    http://xtrema.rtr.gr/beta/xtrema.zip
    Copy the text you want to translate to clipboard, and then,
    from your
    message window, try:
    _d().fromClip().toS(1253).toClip()
    then try pasting the text.
    1253 is the code page for greek.
    For mac code pages supported by windows (values you can pass
    to the toS()
    command), check the second link - for greek, it's 10006.
    http://www.microsoft.com/globaldev/reference/WinCP.mspx
    http://support.microsoft.com/kb/187858
    "Renos83" <[email protected]> wrote in
    message
    news:g1ehdb$a5s$[email protected]..
    > I've written a seminar on Word (Greek & English). I
    want this text on
    > Director.
    > When I copy the Word text and paste it on Director (on a
    text field) it
    > changes the fonts.
    > The problem is that, although I change the fonts on the
    whole text (to
    > "Times
    > New Roman Greek"), the english words sometimes look
    strange. So, I have to
    > mark
    > every english word and change its fonts from "Times New
    Roman Greek" to
    > Times
    > New Roman. As you see, it's a very time-consuming
    process and very
    > exhausting.
    > Is there an easier way doing this?
    >

  • Copy & Pasted text from PDF messes up upper-case words..

    Hey there,
    Have this problem on many PC's in my work, on Windows Vista and Windows 7, using Adobe Reader v9.1.0.
    When highlighting text and copying, then going elsewhere and pasting, the 'case' of the text messes up.
    For example, if I copied:
    "The QUICK brown FOX jumps over the Lazy DOG"
    The pasted text would appear:
    "The QUicK brown FoX jumps over the lazy DoG"
    Is this a known issue? It's doing it on different PC's with different OS's but the version of Adobe Reader is still the same, so it's either an issue with that, or with the PDF's we're reading. They are PDF's of newspapers, but still... text is text, so it shouldn't be an issue!
    It's taking quite a lot of time having to scroll through all this text to make sure all the capitalization is correct (especially when it comes to grammar).
    Just wondering if anyone else has come across this problem, or if there's any known solution!
    Thanks in advance
    -Rhydz

    To copy and paste in a single action:
    tell application "Preview" to activate
    tell application "System Events" to tell process "Preview"
        -- Get the PubMed ID:
        get the title of the front window
        set thePubMedID to word 1 of result
        -- Copy the selected text to the clipboard:
        keystroke "c" using {command down} -- ⌘C
        delay 0.25 -- adjust if necessary
        -- Add the PubMed ID to the contents of the clipboard:
        set theNotes to the clipboard
        set the clipboard to (theNotes & space & "[" & thePubMedID & ".pdf]")
    end tell
    tell application "Notational Velocity" to activate
    tell application "System Events"
        -- Paste the contents of the clipboard to the end of the Notational Velocity document
        key code 125 using command down -- ⌘↓
        keystroke return & return
        keystroke "v" using {command down} -- ⌘V
    end tell

  • Copy paste text from pdf exported from Microsoft.Reporting.WinForms.ReportViewer control with Czech specific characters produced box charactex or ?.

    Used Visual studio 2012. In our project there is used the Microsoft.Reporting.WinForms.ReportViewer control. In the report handled by the control are TextBoxs with a text with Czech specific characters e.g. (ř, ě, ...) . When exporting the report to pdf,
    characters are displayed correctly. However when the text with czech characters in the pdf if copied and  placed into the seach box in the pdf document only box characters are displayed. The TextBox in the report use the default font Arial. When the report
    is exported to Word, and then the Word document is saved as a pdf document, its ok. Coping a text with Czech charactes in the result pdf document and pasting into the search box displays again Czech characters not box characters.
    Also when in the report handled by the ReportViewer control are several Tex Boxes and some of the boxes contains Czech characters and some not, after exporting to a pdf document there is problem with text selection. When in the pdf document I'm trying to
    select several paragraphs, some with Czech characters and some without them, selection behaves strangely and jumps from one paragraph to another unexpectedly.

    Hi,
    did you managed to avoid those squares?
    BTW: if any such char. is encountered in a line, the entire line of text is grabbled.
    I've tried even the ReportViewer from MSSQL 2014, but got the same problem. When I've tried IL Spy, I found a code, where it is checked if the PDFFont is composite - depending on that a glyph is created. But that still only a guess.
    I've tried Telerik's reporting, they have similar problem (beside other), but not with the special characters. They produced scuares for some sequences like: ft, fi, tí.
    Please give any info you got.
    Until then my advices for you:
    a) try JasperReports (seems theyre most advanced, although it is java)
    b) Developer express has quiet quality reports - and it seems they got those special chars. right :D
    c) I created a ticket and waiting for Telerik's response (but if I had to choose reporting, I vould stick with a) or b)

  • How can I copy-paste text from Firefox to Apple Mail preserving all formatting? It works with Safari but not with Firefox, otherwise I'd pick Firefox

    I have a very big list of correspondents to whom I often send articles.
    I cannot copy them from Firefox and paste them onto Apple Mail because they look WEIRD and not at all like the original. Most formatting disappears.
    I do not encounter the same problem with Safari, and THAT is one of the two reasons I am forced to use it even if it gives me lots of problems.
    The other one is that Safari 5 has a built-in RSS reader, which is essential for my work.
    If you could manage to have those two things working, I'd pick Firefox in a second and advertise the fact to thousands who would do the same.

    Try one of these feed readers if the build-in Firefox reader doesn't suit you.
    *Brief: https://addons.mozilla.org/firefox/addon/brief/
    *Sage: https://addons.mozilla.org/firefox/addon/sage/

  • Why are round brackets escaped when copy/pasting URLs from Firefox, in contravention of RFC3987?

    Go to any site, and add a 'hash fragment' to the end of the URL that contains round brackets. Copy that URL out of Firefox and paste into a text editor, like so:
    https://developer.mozilla.org/en-US/#%28testing%29
    Note that the round brackets have been escaped into %28 and %29 characters.
    RFC3987 specifies that "(" and ")" are 'gen-delimiters' are are _not_ equivalent to their escape codes. Replacing these characters with their escape codes is as incorrect (according to the spec) as replacing the "$" or "!" characters (which are not escaped in FF or other browsers) and the "'" (apostrophe) character, which universally is. No, I don't understand it either.
    Worse, this behavior does not match what the other major browsers do, so Firefox has essentially broken the promise that URLs are universal. If there are any reasons for doing this, they have not been made clear or documented, that I can find.
    The hash fragment is increasingly being used to store 'client side' information, and so messing with these characters is breaking applications. I'm trying to understand if there's a good reason why, or just poor programming. In which case, I'll log a bug report.

    Webbrowsers do not use RFC3987 at all. See section 1.2.a about Applicability. Maybe you should have a look at RFC3986 instead.
    What is the delimiting role for the round brackets that would allow their unescaped use?

  • When i paste text from a Word doc into AOL email via Firefox browser, it always pastes: Version:1.0 StartHTML:0000000208 EndHTML:0000004399 StartFragment:0000002624 EndFragment:0000004363 SourceURL:file://localhost/Users, in front of text i want to paste

    only occurs on AOL via Firefox, not on AOL email accessed via Safari .

    only occurs on AOL via Firefox, not on AOL email accessed via Safari .

  • Pasting text from other apps not always work

    Is this a known problem or any way to avoid it? I usually receive emails with copy of text that was already checked for spelling errors, and when I try to copy the text from the email to AE and paste it into the text tool, it does not work 90% of the time, and if it works, it works only once, the next time I copy paste something it keeps always pasting the same old text. I noticed this on all the computers where I have AE installed.
    Thanks
    Victor

    Just a quick update.
    This problem has resurfaced AE CS6 (mac OS 10.8.x) this time.
    The copy/paste into the search bar doesn't seem to work anymore.
    I sent Aobde a note via their Bug/reports page - - (I'd suggest everyone do that.)
    So far, my only working solution is to quit/restart AE. --
    A shame for any 21st century software not to copy/paste formatted, or unformatted text.
    (BTW - the copy/paste text from within AE comps/layers works fine, just not clipboard content from outside .  .  . I'm going to poke around at a few likely culprits and attempt to troubleshoot a solution for my needs, but I can say it's a different problem than my Oct. 2010 post above.)
    Cheers

  • Pasting text from Microsoft Word

    I am working in InDesign on a Windows XP computer. When I paste text from Microsoft Word into InDesign the text loses its formatting such as italics and bold. Is there any way to maintain that formatting? I am supplied with this text by a client and I have so much formatting to do that the projects take me longer than necessary.

    ... and don't forget to run this set of macros in Word BEFORE you do copy/paste ;)
    http://adobescripts.pl/modules/mydownloads/singlefile.php?cid=9&lid=38
    robin
    www.adobescripts.com

  • Cannot paste text from other application into a signed applet in JRE1.4.1

    I have a signed applet. I just upgrade the JRE from 1.4.0 to JRE 1.4.1 (applet has been recompiled with JDK1.4.1). Then I tried to copy-paste text into a JTextArea from another application like Notepad. It doesn�t work. I can only copy-paste text from the applet itself. But this does work when I use JRE 1.40, 1.3.x.
    Thank you for any help.

    Thank you, Viravan.
    http://168.103.84.58/pastetest/test.html
    The link is a test applet. It has two JTextFields and a JButton. You can copy-paste text between the two JTextFields with Ctrl+C, Ctrl+V. But you cannot copy-paste text between the applet and other application such as Notepad, MS Word. It seems that the applet don?t have enough permissions. But it does be signed. I also put a button on the applet and you can use it to browse your local files. That indicates the applet signed well. Fail to copy-paste between signed applet and other application only happen when using JRE 1.4.1. If you use JRE 1.4.0 or 1.3, it works fine.
    The following if the test applet code:
    package test;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    import java.io.*;
    public class PasteTest extends JApplet {
    boolean isStandalone = false;
    JTextField txt1 = new JTextField();
    JTextField txt2 = new JTextField();
    JButton btnOpen = new JButton();
    public PasteTest() {
    public void init() {
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    private void jbInit() throws Exception {
    this.setSize(new Dimension(400,300));
    btnOpen.setText("Select File");
    btnOpen.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    btnSelectFile_actionPerformed(e);
    txt1.setText("Test");
    this.getContentPane().add(txt1, BorderLayout.NORTH);
    this.getContentPane().add(txt2, BorderLayout.SOUTH);
    this.getContentPane().add(btnOpen, BorderLayout.EAST);
    void btnSelectFile_actionPerformed(ActionEvent e) {
    JFileChooser chooser = new JFileChooser("c:\\");
    int state = chooser.showOpenDialog(this);
    File f = chooser.getSelectedFile();
    if(state == JFileChooser.CANCEL_OPTION){
    return;
    else{
    txt1.setText(f.getAbsolutePath());
    Thanks again

Maybe you are looking for

  • FileOpen Plugin not working in adobe reader 10

    Hi, I am using Adobe reader 10 with FileOpen PlugIn. When I am trying to open a pdf in brower i am getting error messages like "This document is not a well-formed FileOpen WebPublisher PDF and cannot be opened". But the same pdf is opening without er

  • Photoshop Web Gallery - how to include home page link

    I have included a web gallery (created in Photoshop) to my website. Everything works fine; however, after scrolling through the photos there isn't a link to help return to the site's home page. The only option is to click the back arrow many times un

  • Apple tv not letting me play movies saying HDCP playback not supported

    Apple tv, go into netflix try to play movies, wont let me say's HDCP playback not supported. Called netflix tryed various things, they believe it's the apple device itself, tryed to contact apple of course you have to buy $35 pkg for support , so now

  • Passing null as input parameter for relational physical DS

    I'm creating a adapter(physical and logical) to talk to a Sybase Stored procedure. A few input integer arguments to the stored procedure are always null From Stored procedures - default NULL , I use xs:int(()) to pass in nulls. But for the 2nd argume

  • Spatial Data in distributed environment

    Hi, I have some question regarding holding spatial data: 1- Is any interchange possible between spatial data via DB Links 2- is it possible to hold spatial data in distributed environments/different instances for several purposes so that a general ap