Have a JTextComponent directly modify a String

I'm at a complete loss, here. What I need to do is have a JTextComponent basically display a String and any modifications to the text in the JTextComponent will mirror in the String - so it's like they're the same.
I've tried several approaches to this...
First try I used a custom DocumentListener (applied to the JTextComponent) which would intercept any changes and basically perform this:
myString = documentEvent.getDocument().getText(0, documentEvent.getDocuiment().getLength());But this would cause dramatic slowdowns if the String contained in the Document was large, and on top of this, each time a character is inserted or removed in the Document, that code was run- even more slowdown!
My second pseudo-try (I couldn't get it to work properly) involved PipedInput and PipedOutput streams. I read that it would be better to have a Thread dedicated to having the PipedInputStream receive data from the PipedOutputStream (configured to monitor the text in the JTextComponent). I didn't get this to work.
Then I started reading up on StringWriter and StringReader. And then ByteArrayInput and Output classes.
I couldn't get anything to work the way I need it to. If anyone has a way that can accomplish this, please let me know!

Okay, so... OOP practices make me feel stupid sometimes. Heaven forbid I just create a Document and have it be a pointer to the JTextComponent's getDocument().
/stupid

Similar Messages

  • The "write key" configurat​ion file vi use of "trim string" prior to writing the data can modify any string data written.

    I tried to use the config VIs to record some front-panel settings for later restoration, one of which could be a single space character (part of a string parsing system).
    I soon discovered that whenever I tried to save that single-space value to an INI file, only a null string was saved.
    After doing some digging I discovered that buried in the Write Key vi is a worker vi called Config Data Modify that uses Trim String on the string data before it is written to the file and that's what was eating my string character. I don't know whether this is a bug or a feature but there are at least three ways to fix it.
    1) Assuming you want to leave the library VIs alone, you can pre-process any stings sent to "write key" to replace all spaces with "\20" and then post-process all strings read using "read key" to replace all instances of \20 with spaces.
      and if you don't mind modifying the library VIs, either to save/use under a different name or to stick back into the library in a modified state (caution - can cause problems when you move code to another machine with an un-modified library) then...
    2) You can yank the trim-string out of the Config Data Modify vi and hope that it does not have any undesirable side effects with regards to the other routines that use Config Data Modify (so far I have not found any in my limited testing)
    or
    3)  You can modify the string pre-processing vi, Remove Unprintable Chars, to add the space character to the list of characters that get swapped out automatically.
    Note that both option #1 (as suggested above) and option #3 will produce an INI file data entry that looks like    key="\20Hello\20World\20"   while option #2 produces an entry that looks like   key=" Hello World "
    The attached PDF contains screenshots of all this.
    Attachments:
    Binder1.pdf ‏2507 KB

    Hi Warren,
    there's a 4th option:
    Simply set the "write raw string" input of the write key function to TRUE
    This option only appears when a string is wired to that function!
    Just re-checked:
    I think it's a limitation of the config file format. It's text based and (leading) spaces in the value are "overseen" as whitespaces. So your next option would be to use quotes around your string with spaces...
    Message Edited by GerdW on 05-02-2009 08:32 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • HT4623 I have followed the directions and my iphone is not installing the iOS 7.0.2.  My iphone is plugged into my lap top that has the most recent version of itunes.  It is a dsl connection.  Is that my problem?

    I have followed the directions and my iphone is not installing the iOS 7.0.2.  I have the most recent version of itunes on my laptop commuter.  my iphone is attached to my laptop via usb port.  The laptop uses dsl not wifi.  Is that my problem?

    Exactly what version of iTunes are you running? And DON'T say 'the latest version'... CHECK the version number. You need to be running 11.1 or higher.

  • I cannot get a TV show from Itunes to play on my Ipad.  I originally downloaded in HD but have since deleted and re-downloaded SD.  I have also downloaded directly to PC and transferred back to IPad without success. It does work on PC

    I recently purchased season 7 of entourage from Itunes and downloaded directly to IPad2.  When I selected to play the tv shows the screen would go black and become disabled.  I have to hit the home page to exit and then search for another movie in my ipad to get access to the library again.  I have tried downloading directly to PC and then transferring to IPad without success.  I don't think it is the download itself because I can play the tv shows on the pc and my iphone.  Am I missing a setting?  also, I can watch other tv shows or movies so my video app is not completely fouled up.

    Sometimes simply restarting your iTunes, the computer and the iPad is all that it takes to correct an issue like this so try that. Quit iTunes, reboot your computer, and restart the iPad. Then try the sync again.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.

  • I have bought music directly on my ipod,i have also bought films and music on itunes on my computer, how do i get them all onto my computer without accidentally deleting everything off my ipod? I did this a while a go and had to spend 100's re-buying

    Help! I have bought music directly onto my ipod, i have also bought films and music directly onto my computer from itunes, how can i put them all onto the computer? My ipod is acting a little odd and i think its going to break at some point, so i really want to save everything i've bought. Last year i tried to sync them thinking that my music would go onto the computer, but it actually just deleted everything off my ipod, i haven't been game to try anything again.

    Transfer iTunes purchases by:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    If you are in the USA and soe other places yu can redownload apps, music, TV show (not movies), books via iCloud. See:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • HT1420 I have the new version of the macbook pro and I cannot find authorize this computer anywhere on itunes. I have read the directions multiple times and still cannot find it. Please help!

    I have the newer version of the macbook pro and I have read the directions on how to authorize your computer to let you download previous song purchases from icloud onto your laptop, but I cannot find where it says "authorize this computer" at all. I have looked for it everywhere and still cannot find it. Please help!

    Authorization and Deauthorization
    Macs:  iTunes Store- About authorization and deauthorization.
    Windows: How to Authorize or Deauthorize iTunes | PCWorld.
    In iTunes you use the Authorize This Computer or De-authorize This Computer option under the Store menu in iTunes' menubar. For Windows use the ALT-S keys to access it. Or turn on Windows 7 and 8 iTunes menus: iTunes- Turning on iTunes menus in Windows 8 and 7.
    More On De-authorizing Computers (contributed by user John Galt)
    You can de-authorize individual computers, but only by using those computers. The only other option is to "de-authorize all" from your iTunes account.
      1. Open iTunes on a computer
      2. From the Store menu, select "View my Account..."
      3. Sign in with your Apple ID and password.
      4. Under "Computer Authorizations" select "De-authorize All".
      5. Authorize each computer you still have, as you may require.
    You may only do this once per year.
    After you "de-authorize all" your authorized computers, re-authorize each one as required.
    If you have de-authorized all computers and need to do it again, but your year has not elapsed, then contact: Apple - Support - iTunes - Contact Us.

  • How do I keep from highlighting terms in the search bar when I modify a string in the search bar--other than by clicking three to five times?

    I'm not talking about terms in the search results; I'm talking about terms in the search string in the search bar in the upper right corner. (Mine is set to use only Google.) When I've searched on a string and decide to modify the string for a second search (say, changing "Spanish architecture" to "Spanish architectural style"), clicking at the end of the search string first highlights the entire string and then, as I keep clicking, highlights various parts of the string. Sometimes it takes five clicks to get the highlighting to go away so I can start back-deleting normally instead of by entire word or phrase. The Google homepage doesn't do this, whereas all search engines in Firefox do it, so it's clearly a Firefox annoyance.

    Left click ONCE to get it's attention. After a moment, then do your work.

  • I bought Adobe Elements 12; I cannot use panorama photomerge, I have followed the directions to go to Full Edit  mode in edit workspace choose File New Photomerge. However the Photomerge does not work, it does not respond.   The only thing I can come u

    I bought Adobe Elements 12; I cannot use panorama photomerge, I have followed the directions to go to Full Edit  mode in edit workspace> choose File> New> Photomerge. However the Photomerge does not work, it does not respond.
    The only thing I can come up with is that I found a blog that said that in the Trial version Photomerge does not work, however I do Not have the Trial version, I did at one time but I purchase Adobe Elements. Thank you.

    The blog was incorrect. Photomerge should work in the trial, too.
    When things get weird in PSE the first thing to do is to delete the prefs. Go to the editor preferences>general, click this button and restart the editor:

  • Bookmarks are saved yet after using the page icon is still displayed instead of the actual icon for the website. I have followed the directions for "Favicons do not display".

    My bookmarks, on a HP Pavilion dv-7-2273cl notebook, are saved yet the page icon is still displayed after using the bookmark instead of the actual icon for the website. I have followed the directions for "Favicons do not display" without any success. This problem is not experienced on my much older Gateway desktop.

    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_places-database-file

  • HT4113 I have followed all directions about restarting my ipod after it has locked, but they have not worked.  What can I do to fix the Ipod?

    I have followed all directions from the website to unlock my ipod when it states Ipod is disabled, but they have not worked.  Is there anything else I can do to unlock the Ipod?

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: Back up and restore your iOS device with iCloud or iTunes
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        
    If problem what happens or does not happen and when in the instructions? When you successfully get the iPod in recovery mode and connect to computer iTunes should say it found an iPod in recovery mode.

  • TS3212 I continue to try to install iTunes; when I attempt to open the newly installed iTunes, I receive errors that it was not correctly installed. I have followed the direction on this website, but I face the same error. Please help.

    I continue to try to install iTunes; when I attempt to open the newly installed iTunes, I receive errors that it was not correctly installed. I have followed the direction on this website, but I face the same error. Please help.

    latest message indicates I need Apple Application Update
    With the Error 2, let's try a standalone Apple Application Support install. It still might not install, but fingers crossed any error messages will give us a better idea of the underlying cause of the issue.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/download.htm
    Right-click the iTunesSetup.exe (or iTunes64Setup.exe), and select "Extract to iTunesSetup" (or "Extract to iTunes64Setup"). WinRAR will expand the contents of the file into a folder called "iTunesSetup" (or "iTunes64Setup").
    Go into the folder and doubleclick the AppleApplicationSupport.msi to do a standalone AAS install.
    Does it install properly for you?
    If instead you get an error message during the install, let us know what it says. (Precise text, please.)

  • Excel file whose cell characteristics have been changed to "modified" automatically.

    I have an Excel file whose
    cell characteristics have been changed to
    "modified". I did make a new file few days ago
    and filled with data, I have
    always considered whether the cells are
    in default. This morning
    I opened the file and (almost)
    all cells are again adjusted.
    Do you know why this happened? If so,
    when can I do to resolve this?
    With Kind Regards, F. van 't Hoff

    Hi,
    If you had an external data source which linked with the Excel file, please check the data setting in "Data tab>Refresh add drop down arrow>Uncheck
    Refresh data when opening the file".
    If your file had some formulas, please try to set it calculation manually
    Formulas>Calculation Options>Manual.
    Thanks,
    George Zhao
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click "[email protected]"

  • I have an iPhone5. I update to iOS7. Now I cannot edit my messages. I have to delete the whole message string like in iPhone 1. What has gone wrong

    I have an iPhone5. I updated to iOS7. Now I cannot edit my messages. I have to delete the whole message string like in iPhone 1. What has gone wrong?

    Thanks it resloved my question, but Apple has made it more complicated it was so much easier to just press the edit button and select messages to be deleted. Now its cumbersome to delete several messages. Apple should give us back the edit button.

  • Modifying a string...

    I'd like to modify a string. I wanna replace a substring of the original string to another substring. I was looked for a method in Java API, but i didn't find the perfect, because there is a replace(char,char) method, but i don't want to replace just 1 character. Please, help me. Thanks.

    Since JDK 1.4 there is a [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)]replaceAll method that performs regex matching. This will return a new String and will not change the original one since String is an immutable class
    Mike

  • Modifying a string in a DLL

    I am using the flexible DLL prototype adapter to pass a test stand string (local). I wish to modify the contents of the string within the body of my DLL 'C' Function.
    When I try to use a type that will allow the code to make the modifications on the test stand variable, Test Stand generates an error when it checks my type library.
    I have tried using the following string types in my code:
    LPCTSTR* pszString
    BSTR* pbstrString
    Both types generate a type not supported message in Test Stand.
    Is it possible to perform this action using test stand?

    Hi C_Test,
    A character string (char[]) can be modified inside a DLL call. Just as Ron said, to TestStand this is C String Buffer which is modifiable from the C DLL.
    Attached is a zipfile containing a sequence file (teststring.seq) which calls a Visual C++ 6 DLL that contains one function takes one input parameter (char mystring[1024]). The input string is modified, and the sequence file displays before and after message popups to show that this works.
    Regards,
    David Mc.
    National Instruments - Applications Engineeing
    Attachments:
    teststring.zip ‏261 KB

Maybe you are looking for

  • Windows 8.1 Pro 64 bit

    I have an Envy X2 11-g001tu (Australia) on which I am currently running Windows 8 Pro 32 bit which is very stable. I have tried to upgrade it a couple of times to 8.1 Pro 32 bit and it becomes unstable, so I have to revert, which is time consuming an

  • Convert TIF Binary data to PDF Binary data

    Hi All, I have uploaded TIF file into table in system in Binary format. I need to create a spool from this Binary data, the spool should open in TIF format or PDF format. Can you help me in doing this. As I knw how to convert PDF to Spool, it would b

  • Executing a procedure - Works on Isql Plus but not SQL Developer??

    Hi folks. I am playing around with some design and structure stuff, mostly just passing values around procedures. I have one procedure (procedure1) which takes a sysdate and then passes it to another procedure (procedure2) which takes the parameter a

  • Ipad 3 AVCHD files

    Does anybody know how to import AVCHD files direct  into an ipad 3 using the camera connection kit without having to download and convert in a Mac first? Motion Jpeg and jpegs are fine but I much prefer the quality of AVCHD, any suggestions very welc

  • Can we force InDesign to look for links in current directory.

    An InDesign document has links to images/InCopy stories located at some location,say, "Dir_1". The copy of all the linked items are present in current directory of InDesign document. When we open this document in InDesign CS3 , the document is linked