Modify StyledEditorKit's text without losing text formatting

How do i modify text in a StyledEditorKit (RTFEditorKit in my case) without losing the text's format/style?
This is my code right now. Whenever i modify the text, the modified part reverts back to the default font, size and style.
          toUpper = new myAction("To Upper Case", new ImageIcon(), "", new Integer(KeyEvent.VK_U))
               public void actionPerformed(ActionEvent ae)
                    try
                         String s = FileIO.fio.ep.getSelectedText().toUpperCase();
                         int start = FileIO.fio.ep.getSelectionStart();
                         int end = FileIO.fio.ep.getSelectionEnd();
                         FileIO.fio.ep.getDocument().insertString(end, s, null);
                         FileIO.fio.ep.getDocument().remove(start, end-start);
                    catch (CannotUndoException e) {}
                    catch (Exception e) { /*e.printStackTrace();*/ }
          };FileIO.fio.ep is a JEditorsPane with the RTFEditorKit installed
FileIO.fio.rtfek is the RTFEditorKit
Edited by: h_howee on Apr 29, 2008 4:36 PM

You pass null here.
FileIO.fio.ep.getDocument().insertString(end, s, null);
That's why the attributes are reset.
You mut get proper attributes and pass them in the method.
Cast the FileIO.fio.ep.getDocument() to StyledDocument, get Character element from the document using caret postition and get the attributes from the element.
Regards,
Stas

Similar Messages

  • If I donwload e-books from various e-book retailers and want to back them up on an external hard drive without losing the format, do I need a special hard drive?

    If I download e-books from various e-book retailers and want to back them up on an external hard drive without losing the format, do I need to know anything special?

    I just looked into this as I was moving my iPad to a new computer for synching.  With no thanks to Kobo for any really useful information on their help site (this discussion was the most useful info I found), I think the following may address your issue with respect to Kobo.
    1. There is not easy or official way to back up Kobo books from your iPad.
    2. Kobo keep track of your personal library.  Go to the Kobo website (Kobo.com) and sign in to your account.  On the very top line is "My Library".  That contains (or at least Kobo says it does) everything you have ever bought from Kobo.  Kobo say that you may download any of this content to other devices you own at no charge.
    3. I synched my iPad to the new computer.  According to Apple, that will delete all my data as the apps are re-installed from the new compute.  While all my apps got moved around from the order I previously had (many thanks Apple), all my books are still there together with my bookmarks etc.  Looks like this did nothing to change any Kobo data.
    While I do not like the idea that I cannot create a backup on my main computer, it is probably safer in the long run that there is a backup at Kobo.  After all, I could lose all my equipment in a fire or something, and then personal  backups would be of little use.

  • How do I duplicate a spreadsheet, then delete all content without losing the formatting?

    I am using numbers to do my accounting for my business. I have created a spreadsheet with pre-formatted columns which is proving VERY useful. I have a drop-down list of "suppliers" which I will add to each month but the problem I have is that when I try and duplicate the spreadsheet (ready to start scratch for next months accounts) I'm struggling to delete all the data from the spreadsheet WITHOUT losing the formatting.
    Any help is appreciated.

    "Okay so to be more specific there is one particular column called "suppliers" which is formatted to be a drop down menu. This menu will be added to monthly thus growing larger and becoming comprehensive. What's the best approach to be able to start fresh every month but with the most recent and up-to-date "suppliers" menu?"
    I'd suggest using a two template (or template plus document) approach.
    The template would include the message "Paste POP-UP Here. Fill down" in the top cell of the Suppliers column.
    The second template (or regular document) contains the current version of the pop-up menu cell.
    Open both,
    in the single cell document, select and edit the pop-up menu to include the added suppliers. When done, select the cell and Copy.
    Switch to the document produced by the main template. Select the cell with the message (and the rest of the column below that cell) and Paste.
    You now have an empty spreadsheet with pop-up containing the current supplier list.
    If you add a supplier in mid month, you can add that supplier to the pop-up menu in the current row of the document, and Fill the edited menu down from there.
    At the end of the month, if you have made additions to the menu list, select and copy a cell containing the most recent version, switch to the single cell document, select that cell and Paste. This updates the single cell to contain the current version of the pop-up menu, ready to be pasted into the next month's document.
    Regards,
    Barry
    PS: On re-readiing this, I'd also consider skipping the production and saving of the one cell document. The most current version of the pop-up menu will be the one at the bottom of the Suppliers column of the month just ending. That cell can be copied, pasted into the top cell of the column in the new month's table/document, then reset to the 'no entry' item, then filled down the column.
    B

  • How can I paste an MS Word document directly into gmail using Firefox browser, without losing all formatting?

    I'm trying to paste a simple MS Word doc directly into the body of a Gmail email, but all formatting goes out the window. I've tried downloading a couple different HTML editors, including CoffeeCup (which doesn't work with Firefox) and Firefox's own Firebug, which, quite frankly, no one on this end can figure out (doesn't seem to be as user friendly as CoffeeCup). Please advise, as this will be an ongoing operation which we'll need to be able to perform. Thanks.

    First, thanks for your reply. It's greatly appreciated. However, the level of your response fails to address the scope of the original question. Your first supposition is incorrect, that most MS Word docs copy uneventfully into the body of Gmail emails. This only applies to the most basic of MS Word docs (i.e., those utilizing minimal formatting, such as basic letters, etc.) and otherwise runs contrary to dozens of online complaints posted by users such as myself (though not on the Firefox website). Second, everyone knows you can add an attachment to Gmail emails. In this case, the recipient will not accept attachments of any kind, and has therefore asked that the content be copied directly into the email body. This is not uncommon in these cases. Third, the very nature of Notepad makes it unable to translate/interpret any documents beyond the most basic, hence its name: Notepad. Fourth, apparently this problem is rare or virtually non existent with other browsers, as all the complaints online appear to be Firefox related. Again, however, I appreciate you taking a stab at this.

  • Converting PDF files with tables back to Microsoft Word without lossing the format

    I am trying to convert a large amount of PDF files that has tables on them (some are filliable Forms). I need to convert the files to Microsoft Word 10. I have tried to convert the files by using the export option but it would lose the format and the tables would go crazy. Is there a software that I could buy or a process that I could use to get the files to export the files without losing the format. Hopeful I have explained this issue clear enough in order to get help.

    That suggests that the PDF was not created with PDF Maker that retains the format information. As a result, there is not much you can do with Acrobat if it is not converting properly. You can try to save as HTML or RTF and import those into WORD. Sometimes those conversions will do better, but not real sure.
    You can also use a copy and paste from the PDF with the alt key held down to force the column mode of copy. Unfortunately, with Acrobat there is not much more you can do. There are some 3rd party products that focus on the conversion to WORD and I understand do a much better job for the type of untagged document you likely have. Check with PDF Zone or Planet PDF for the 3rd party solutions. Be aware, they are not cheap either.

  • How to import xfa(XML Forms Architecture) to indesign without losing rich text format.

    Hello All,
    i created pdf form in livecycle.i am populating this pdf form and submit.when i am submiting form ,i will get the data in xfa(xml forms architecture).now i want to import this xml to indesign.when i importing this xml to indesign,it imported without rich text format.this means in indesign formate is not preserved when importing xfa(xml forms architecture).
    how to import xfa(XML Forms Architecture) to indesign without losing rich text format.
    please help me,its urgent.
    thanks
    Humayoo

    I really have no idea what kind of file that is and how is the structure, but if it´s valid XML, I guess you could use InDesigns Tags to Styles mapping engine to format incoming stuff....

  • Is there a way to scroll between footnotes in the new pages version and to actually copy an old text with footnotes into the new version without losing them or having them in the text?

    Since my update I am no longer able to scroll between the footnotes. I have to klick on each one to change something. That is unbearable since I have to write a lot of academic texts which usally have a ton of different footnotes. I also can not copy some of my old texts into the new version without losing the footnotes or having them in the middle of my text. Does anyone know a trick or if apple will change that for good? Thx for any support - it really drives me crazy

    Isn't that you asking how to get it (undefined) back?
    If you never had Pages '09, you can buy it from Amazon very cheaply:
    http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=432&sid=f68e84cd2ec6 123bd2ed93806c7e7fb6&mforum=iworktipsntrick
    Peter

  • Is it possible to store text in a table(colom) without losing the layout

    hello,
    I have a question and the question is:
    Is it possible to store text in a table(colom) without losing the layout?
    For the people who don't know what i presicly mean i will explain my question:
    Think of a memo field, i write a memo with bij example word or an internal editor of oracle, and if i wan't to store it in a colom with out losing the layout wich datatype for the colom should i use(if this is posibble).
    So when i whant to review the memo it has the same layout as when i wrote the memo.
    I hope someone can help me,
    thanks by regards,
    Menno

    Is your text field ("memo field") containing only text
    (ie of type VARCHAR2 or CLOB) ?
    If so, it should preserve your line returns and spaces.

  • Can anyone tell me why I am unable to download a template word doc from webmail onto my mac without it opening in text format? I just need the original document format.

    Can anyone tell me why I am unable to download a template word doc from webmail onto my mac without it opening in text format? I just need the original document format.

    Where to begin... and why would you ask here? (workstation owners)
    Places I can think to try, after google of course....
    Forum devoted to something like Word / Mactopia or Pages.... whether you are using Office 2011, and no idea what browser or webmail (IMAP, Gmail, other)
    And then there really are notebook with subforum for MacBook Pro
    Apple Site Map
    Apple Support Mail
    Apple Support

  • How can I convert text to PDF in the new "Pages" without losing info.

    How can I convert text to PDF in the new "Pages" without losing a lot if information?

    Select Export To from Pages' File menu, then select PDF from the sub-menu.

  • Does anyone know, if I can place the footnote text in another textframe without losing the cross references?

    does anyone know, if I can place the footnote text in another textframe without losing the cross references?

    Bleib sachlich Django, deine persönliche Meinung interessiert nicht. Wenn du nix zu sagen hast, dann bitte raushalten.
    Von meinem Windows Phone gesendet

  • Delete some text from textItem without losing styles

    If I have a type layer with a bunch of styles applied to different style runs within the text, is it possible to delete some of the text without losing the styles applied to the remaining text?
    To accomplish the same thing, would it be possible to create a new type layer and copy some of the text from the original type layer to the new type layer while preserving the styles?

    If I have a type layer with a bunch of styles applied to different style runs within the text, is it possible to delete some of the text without losing the styles applied to the remaining text?
    To accomplish the same thing, would it be possible to create a new type layer and copy some of the text from the original type layer to the new type layer while preserving the styles?

  • All backup/sync files for Iphone lost on old PC, anyway to sync with new PC without losing music, photos, contacts and texts?

    All backup/sync files for Iphone lost on old PC, anyway to sync with new PC without losing music, photos, contacts and texts?

    Make sure your new computer is authorized in iTunes. Disable autosync in itunes, connect your iphone, right click on it in the device list and choose backup.
    This will save data, pictures and settings to itunes. See what's included in this backup here: http://support.apple.com/kb/HT1766
    Transfer your purchases the same way to copy all apps and bought media from the Store to your computer.
    Set up at least one contact and event on your computer to be able the merge your calendars and contacts after your device got wiped during the first sync.
    The rest of the data can be restored from the backup you made.
    Restoring: http://support.apple.com/kb/HT1414
    Music is one way only, from the computer to your device, unless you bought the songs in itunes and transferred your purchases.
    Apps can be downloaded again for free, in the US music as well. Downloading past purchases from the App Store, iBookstore, and iTunes Store
    There is 3rd party software out there, but not supported by Apple, see this thread: http://discussions.apple.com/thread.jspa?threadID=2013615&tstart=0
    See also How to back up your data and set up as a new device

  • HT201210 how can i get my iphone 4 out of recovery mode without losing text messages and pictures and contacts

    my phone is stuck on the screen with the charger pointing up to itunes. Itunes says it can't find it in recovery mode. How do i get my phone out of this setting without losing everything that has been on my phone

    nina38 wrote:
    How do i get my phone out of this setting without losing everything that has been on my phone
    You don't.  so hopefully you've been keeping regular backups.

  • Excel to pdf and back without losing formatting

    I have created an Excel spreadsheet to become a fillable form and have to add new information to the original excel file that is to be included on the fillable form. How do I do this without losing all of the work I created on the fillable form ie text, check, radio buttons and formatting of fields

    Hi,
    You may open that converted pdf form in Acrobat.
    Go to > Tools > Forms > Edit.
    Then make changes you would like to add for form fields.  And if you want to Edit text. Toos> Content Editing.
    Regards,
    Ajlan Huda.

Maybe you are looking for