JTextPane and the default PasteAction

Now here's a really bad problem. I'm writing a custom word processor in Java (isn't everyone?). I'm using a JTextPane, with an assigned HTMLEditorKit and an assigned HTMLDocument. Code as shown below:
    this.vHtmlPane = new JTextPane();
    this.vHtmlKit = new HTMLEditorKit();
    this.vHtmlPane.setLayout(new BorderLayout());
    this.vHtmlPane.setEditorKit(this.vHtmlKit);
    this.vHtmlDoc = new HTMLDocument();
    this.vHtmlPane.setDocument(this.vHtmlDoc);
    this.vHtmlDoc.addUndoableEditListener(this.vUndoMgr);So far so good. Now, following all the documentation I could find, setting up cut and paste is as easy as the following:
    JMenu mEdit = new JMenu("Edit");
    mEdit.add(this.getActionByName(this.vHtmlKit.cutAction));
    mEdit.add(this.getActionByName(this.vHtmlKit.copyAction));
    mEdit.add(this.getActionByName(this.vHtmlKit.pasteAction));Where getActionByName() is implemented from:
  private void createActionTable(HTMLEditorKit htmlKit) {
    this.vActionMap = new HashMap();
    Action[] actions = htmlKit.getActions();
    for(int i = 0; i<actions.length; i++) {
      Action a = actions;
this.vActionMap.put(a.getValue(Action.NAME),a);
private Action getActionByName(String name) {
return (Action)(this.vActionMap.get(name));
The problem is when I go to paste something using ctrl-v (I'm developing on WinXP). I get an IllegalArgumentException followed by a whole lot of nullpointers and then everything goes to hell. My work machine just hangs, and my home machine reboots. The circumstances are like so:
ctrl-c from Textpad or Notetabpro or any true text editor - works fine.
ctrl-c from Mozilla or anything that adds anything remotely like html code to the clipboard - hell in a handbasket.
I've traced the problem through several levels of the core JDK, and it seems that all the screaming starts in the TransferHandler classes importData(JComponent comp, Transferable t) method. Something about that and the interaction with the HTMLDocument trying to handle the import of html tags. Beyond that I'm kinda stumped. I would have thought that the default behaviour for an HTMLDocument paste would be to url-encode incoming text, but it seems that it pastes it wholesale, at which point the HTMLDocument refreshes and chokes on the tags it did not generate.
I would appreciate any insight into how to override the default paste action or even better, how to fix it so the default paste action stops blowing up the app. I'd write my own default paste action without bothering the luminaries on this board, but after diving several levels into the EditorKit and finding such things as Flavor and Transferable classes and a PasteAction married to the EditorKit class... it just seemed like I must be missing the trick somehow.
The particulars:
Jdk: Sun 1.4.2_04
IDE: JBuilder X patch 3
WinXP sans the e-vile SP2 (so I'm on SP1)
Anyone have any ideas?

A little more background...
I traced a paste event all the way through, and I'm getting the fatal error at line 231 in HTMLEditorKit:
    public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException {
     if (doc instanceof HTMLDocument) {
         HTMLDocument hdoc = (HTMLDocument) doc;
         Parser p = getParser();
         if (p == null) {
          throw new IOException("Can't load parser");
         if (pos > doc.getLength()) {
          throw new BadLocationException("Invalid location", pos);
         ParserCallback receiver = hdoc.getReader(pos);
         Boolean ignoreCharset = (Boolean)doc.getProperty("IgnoreCharsetDirective");
         p.parse(in, receiver, (ignoreCharset == null) ? false : ignoreCharset.booleanValue());
         receiver.flush();
     } else {
         super.read(in, doc, pos);
    }Line 231 is the receiver.flush() call, at which point a RuntimeException is thrown and caught at line 212 in the EventDispatchThread class pumpOneEventForHierarchy method.
C'mon guys - this has got to be a bug! I traced while pasting some text from Notepad and that went fine. Then I pasted from Mozilla, and got the above. I can't see the state of the objects in the core Java classes (can't seem to get JBuilder to show that), but that's what's happening.
I'm going to hit post on this now, and then stop runtime debugging on JBuilder and watch my computer reboot. Can anyone shed some light on this???

Similar Messages

  • When I try to open an image by double clicking on it in Bridge, I get a message telling me to log in to Creative Cloud.  I am running CS6, and the default should be to open files in Photoshop 6 or in Adobe Raw (if it's a Raw file).  I don't want to log in

    When I try to open an image by double clicking on it in Bridge, I get a message telling me to log in to Creative Cloud.  I am running CS6, and the default should be to open files in Photoshop 6 or in Adobe Raw (if it's a Raw file).  I don't want to log into CC since I am not a subscriber, and this means that I have to work around, and go  back to Bridge, and tell it to open the file in Adobe RAW.  However, this does not work for older psd files which for some reason cannot be opened in RAW.  How do I return to the process of simply allowing RAW files to open automatically in Adobe RAW, and simply right clicking on the image in Bridge to bring up the option of opening it in Photoshop?

    <moved from Adobe Creative Cloud to Bridge General Discussion>

  • I installed iWork11 but the '09 versions of the software are still running--and the default. What do I need to do to get the '11 versions working?

    I installed iWork11 but the '09 versions of the software are still running--and the default. What do I need to do to get the '11 versions working?

    It's very simple. If you want to use iPhoto, just let it manage things as it does. Other than that: Export from iPhoto and delete the image from iPhoto. That will remove the master and all versions.
    If space is an issue... use an external disk.
    Don't change anything in the iPhoto Library Folder via the Finder or any other application. iPhoto depends on the structure as well as the contents of this folder. Moving things, renaming things, deleting them or otherwise making changes will prevent iPhoto from working and could even cause you to damage or lose your photos.
    Regards
    TD

  • If Firefox 20 is in Private Browsing mode then a possible persona is disabled and the default theme is used - oh god, no - what can I do to keep both?

    Cor-el answered on the 4.4.13: " If Firefox 20 is in Private Browsing mode then a possible persona is disabled and the default theme is used. So you will have to make a choice."
    Can I go back to an older version of FF? I really do not want to choose. Will that problem be fixed in FF 21? I really love Firefox, it has always been my favorite browser - but giving up the Personas will be hard and I don't understand why I have to...
    How do I reinstall an older version of FF? Is there another solution?

    Remember to use the per window Private Browsing when you are doing banking or other confidential / financial work.
    One option is now
    * '''Firefox Button -> New Private Browsing Window'''
    * (Linux / xp File -> New Private Browsing Window)
    * see [[Private Browsing - Browse the web without saving information about the sites you visit]]
    You may even benefit from saving your History.It improves the functionality of the location bar / ''awesome-bar ''
    *[[Awesome Bar - Find your bookmarks, history and tabs when you type in the address bar]]

  • TS1702 I REMOVED YOUMAIL APP FROM MY PHONE AND THE DEFAULT GREETING FROM THE APP STILL ANSWERS MY PHONE  HOW DO I GET IT NOT TO?

    I REMOVED THE YOUMAIL APP FROM MY PHONE AND THE DEFAULT GREETING FROM THE APP STILL ANSWERS MY PHONE,
      HOW DO I GET IT NOT TO?

    As Dah•veed said, you can delete an app on one divice, and still have it stay on another. The syncing only applies for downloaing apps when you have "Sync Purchases" enabled for the App Store. This goes for the iTunes, iBooks, and Podcasts apps as well.

  • User.region and the default locale

    What is the difference between user.region, user.country and the default locale.
    Thanks

    Same problem here ! I called Apple Care and got two people during 2 hours on call, they were unable to explain why and just repeat that "the use of TVout for recording purpose are not supported by apple".
    Why this settings has to be hidden ?
    FYI : i'm able to capture Ipad 2 thru BMD Intensity Pro but not able to switch PAL and NTSC in TV OUT settings to get a correct input. TV OUT setting doesn't appear.

  • OutlineField and the Default Button

    Hello all,
    We are currently using the Forte 3.0.G.2. I have recently come
    across the situation where I am unable to understand the behavior of the
    default button. The situation is this:
    Whenever I am including the Outline Field as one of the widgets in
    any of my windows that particular window will not respond to the default
    button. I am attaching the pex file so you can run the test windows and see
    the problem.
    Can someone please tell me if I am doing something wrong or is this a
    known/unknown bug?
    <<DefaultBtn.pex>>
    Thanks in advance.
    Kamran Shafi
    Systems Engineer
    EDS Medi-Cal XIX
    Phone: (916) 636-1093
    Email: [email protected]

    Hi Kamran!
    What happens is that when the focus is on outline fields, the enter key
    fires a doubleclick event and ignores the default button. So you need to
    capture the doubleclick event and do whatever you want your button to do.
    Here's a quote from Forte support
    "Unfortunately, this is a documentation issue. The IsDefaultButton only
    works when focus is on a simple DataField, because in all of the complex
    fields, including TextField, TextEditField, TreeView and ListView as well
    as OutlineField, the Enter key has a separate and defined action. On
    Tree/ListViews and OutlineFields that is DoubleClick.
    You COULD catch the DoubleClick on the OutlineField and post a click event
    on the default button, however I'd encourage caution with that, since this
    could cause some unexpected behavior if someone were counting on the Enter
    (or a mouse double-click) to behave in our standard way."
    Andrew Small
    Enterprise Distributed Solutions National Practice
    BORN Information Services
    [email protected] <mailto:[email protected]>
    -----Original Message-----
    From: Shafi, Kamran [mailto:[email protected]]
    Sent: Thursday, July 08, 1999 12:49 PM
    To: [email protected]
    Subject: OutlineField and the Default Button
    Hello all,
    We are currently using the Forte 3.0.G.2. I have recently come
    across the situation where I am unable to understand the behavior of the
    default button. The situation is this:
    Whenever I am including the Outline Field as one of the widgets in
    any of my windows that particular window will not respond to the default
    button. I am attaching the pex file so you can run the test windows and see
    the problem.
    Can someone please tell me if I am doing something wrong or is this a
    known/unknown bug?
    <<DefaultBtn.pex>>
    Thanks in advance.
    Kamran Shafi
    Systems Engineer
    EDS Medi-Cal XIX
    Phone: (916) 636-1093
    Email: [email protected]
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • My "go to in point" and "go to out point" keyboard shortcuts are not working, and the default keys arnt either? any help would be amazing!

    my "go to in point" and "go to out point" keyboard shortcuts are not working, and the default keys aren't either? any help would be amazing!  I use these keys a million times a hour and since I have switched to cc I cant get them to work. track selection makes no difference or if there are markers on the timeline or not. 
    Anyone else feel me on this?
    any help?

    Well that still didn't make any kind of difference.  I would just do without it but I've becomes really use to it with Avid for so long.  I have to admit there are a lot of small moments like this that makes me miss Avid.  Any other suggestions? I have checked the keyboard shortcuts a few times and maybe I'm just missing something here...

  • How do I revert back to the old operating system?  The new upgrade that came out totally disabled my WiFi and the default backgrounds changed to white instead of bla k.

    An upgrade was sent to my Samsung Galaxy S5 phone on 3/27/15 and it ruined my phone.  I no longer have the ability to Wi-Fi.  When I swipe the phone on there is a clicking sound and the scree goes directly to my keypad.  I want the phone to go to my home screen like it did before.  My apps that had a black background now have a white background which is impossible to see outdoors.  I want the black background back for settings, clock, and calculator.  Samsung tech support says this stuff is default with the new upgrade.  How do I revert back to the version I had before without having to put the phone back to factory settings and lose all my pictures, memos and other files I have accumulated over the last year that I have had the phone.  I am desparate.  Please help me.  Send an e-mail to (removed)
    >> Edited to comply with the Verizon Wireless Terms of Service <<
    Message was edited by: Verizon Moderator

    You cannot revert back without voiding warranty and we cannot discuss the methods to do so.

  • Tab Bar Control and the Default "More" Behavior

    I've got a client who wants an app with 8 tabs. The only problem is that they don't like the default "more" behavior with the tableviewcontroller containing the extra tab content. What they want is to hit "more" to see the next four tabs replace the first four and then to toggle back if it's hit again.
    There are a few ways to do this, I guess. I could build a second viewcontroller/tabcontroller that comes on or leaves when "more" is touched. Is there a surer way of doing this? I'm sure I'm missing something basic, but I've googled my brains out on this one and just can't see it.

    You could use one TabbarController with 8 ViewControllers, and rotate them when the More tab is tapped:
    - (BOOL)tabBarController:(UITabBarController *)tbc shouldSelectViewController:(UIViewController *)vc {
    if (vc == tbc.moreNavigationController) {
    NSMutableArray *newVCs = [[NSMutableArray arrayWithCapacity:8] retain];
    for (int i = 0; i < 8; i++) {
    [newVCs addObject:[tbc.viewControllers objectAtIndex:(i + 4) % 8]];
    tbc.viewControllers = newVCs;
    [newVCs release];
    return NO;
    } else {
    return YES;

  • The APP store wants me to sign into itunes store and the default Apple ID it displays is wrong

    I have iPhone 5c.
    OS 8.3
    When trying to get an update at the App store, the prompt says sign in to iTunes store but the default Apple ID it shows is not mine.
    I can sync OK and access my account and everything else shows the correct Apple ID.
    How do I get the default Apple ID that is displayed changed?

    What that means is that the Application you were trying to update was either purchased or downloaded to that device by a different Apple ID.
    Cheers,
    GB

  • How to change the java control panel and the default java in windows.

    Hi,
    Please help on the above problem. I need the answer urgently.
    I have two java version 1.4 and 1.5. I first installed the java version 1.4.2_06 and then 1.5.0_19.Now the default java is 1.5.
    Now I want to chang the java settings to 1.4 by changing the envioronment variable (classpath,path,java_home)
    C:\Program Files\Java\jdk1.5.0_09;C:\j2sdk1.4.2_06
    C:\Program Files\Java\jdk1.5.0_09\lib;C:\j2sdk1.4.2_06\bin
    C:\Program Files\Java\jdk1.5.0_09\bin;C:\j2sdk1.4.2_06\bin
    But after setting these does not solve the problem. The java control panel which appears is the same what was appearing for java 1.5.
    I want to see the control panel for 1.4.2_06.
    Thanks for your help.
    Regards,
    Sarita

    sarita2320 wrote:
    ..Please help on the above problem. I need the answer urgently. ...Is it still urgent?
    When I opened your post and saw that line, I immediately moved it to the 'last in line' of a whole bunch of other stuff I did not have time to look at immediately. Now that all that other stuff that did not bore me with someone else's time constraints is out of the way/taken care of, I've returned to your post.

  • Problems with vertical cell borders and the default table style

    When laying out tables in Word, I like to use thin horizontal lines (cell borders) and thick-ish white vertical lines. The vertical white cell borders create a subtle negative space that is less cluttered than the typical boxed-in-all-sides style.
    Issue 1.
    In Pages, horizontal cell borders seem to take precedence over vertical cell borders so my vertical white line trick doesn't work. Is there a way to force my vertical white cell borders to "show up" over my think black horizontal cell borders?
    Issue 2.
    So, for the time being, I'm not using vertical white cell borders in tables; instead, I set the vertical cell borders to "none." Unfortunately, when I try to set the default table style using a table with no vertical cell borders, Pages adds the vertical cell borders anyway. Does anyone know a way to get Pages to surrender?
    Message was edited by: Steve in Seattle

    I must apologizes.
    It seems that I didn't understand well the problem.
    Issue 1.
    In Pages, horizontal cell borders seem to take precedence over vertical cell borders so my vertical white line trick doesn't work. Is there a way to force my vertical white cell borders to "show up" over my think black horizontal cell borders?
    NO
    Issue 2.
    So, for the time being, I'm not using vertical white cell borders in tables; instead, I set the vertical cell borders to "none." Unfortunately, when I try to set the default table style using a table with no vertical cell borders, Pages adds the vertical cell borders anyway. Does anyone know a way to get Pages to surrender?
    I checked and here, aftere defining a new default format with vertical lines set to none, this format is used when I cvreate a new table.
    But the same with horizontal lines doesn't apply.
    _Go to "Provide Pages Feedback" in the "Pages" menu_, describe what you wish.
    Then, cross your fingers, and wait _at least_ for iWork'10
    Yvan KOENIG (from FRANCE mardi 28 avril 2009 22:31:45)

  • JTextPane and the direction of "textflow"

    Hi, I got a kinda strange question.
    What i want to do is to make the text in a JtextPane go from bottom and move up. The textpane wont be editable for the user.
    That is: The text should show up at the bottom of the view and move up in the view as more text is added.
    I could solve this somewhat unintelligent by adding an invisible box (Box.createVerticalStrut ) at the beginning of the text. The height would be the same as the viewport the textpane is inside. But are there more elegant solution? Scrollbars would be added as soon as the first line is entered into the textpane, and thats a less than ideal solution.

    A little more background...
    I traced a paste event all the way through, and I'm getting the fatal error at line 231 in HTMLEditorKit:
        public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException {
         if (doc instanceof HTMLDocument) {
             HTMLDocument hdoc = (HTMLDocument) doc;
             Parser p = getParser();
             if (p == null) {
              throw new IOException("Can't load parser");
             if (pos > doc.getLength()) {
              throw new BadLocationException("Invalid location", pos);
             ParserCallback receiver = hdoc.getReader(pos);
             Boolean ignoreCharset = (Boolean)doc.getProperty("IgnoreCharsetDirective");
             p.parse(in, receiver, (ignoreCharset == null) ? false : ignoreCharset.booleanValue());
             receiver.flush();
         } else {
             super.read(in, doc, pos);
        }Line 231 is the receiver.flush() call, at which point a RuntimeException is thrown and caught at line 212 in the EventDispatchThread class pumpOneEventForHierarchy method.
    C'mon guys - this has got to be a bug! I traced while pasting some text from Notepad and that went fine. Then I pasted from Mozilla, and got the above. I can't see the state of the objects in the core Java classes (can't seem to get JBuilder to show that), but that's what's happening.
    I'm going to hit post on this now, and then stop runtime debugging on JBuilder and watch my computer reboot. Can anyone shed some light on this???

  • How can I change the color in a search window for visited sites? I'm partially color blind and the default colors are very difficult to tell from one another.

    When I'm looking at a search engine results page, I would like the colors of visited results to be a color that is much more different than they are now. Like blue v.s. black or blue v.s. yellow.

    You can use the NoSquint extension to set font size (text/page zoom) and text color on web pages, including the visit color.
    *NoSquint: https://addons.mozilla.org/firefox/addon/nosquint/

Maybe you are looking for

  • I receive message the CC desktop needs to upgrade and the upgrade fails to complete

    I have tried many times and the upgrade fails at the same place, almost to the far right end of the progress bar. I have downloaded to my PC and tried from there as well as the automatic upgrade the happens when I try to acces CC desktop. I'm running

  • Using a different icon

    Hi everyone, I have just created 3 captivate movies & a menu for a client & I have just been aske if it would be possible to use there own icon rather than the standard captivate image that is used when the exe file is created. I did not notice any o

  • Should the LabVIEW program be reduced to the speed of data collection?

    I'm using a LabVIEW program created by Ocean Optics for a Spectrophotometer probe with is run through the USB port. The problem occurs when we attempt to collect data over a time frame of one second. For some reason the whole LabVIEW program will beg

  • Office 2010 Workgroup Templates

    Dear Community, We are currently having an issue where the clients are closing outlook and reciving a popup to save NormalEmail.dotm. The users do not have a normalemail.dotm file located under %appdata%\Microsoft\templates folder and when we add the

  • Pricing Procedure - Account Determination

    PO: During price determination, How does Condition type (example ZSPI), should post to GL# 123XXX. -We want to create PO condition type for VAT which will post to perticular GL! -where does Condition Type <> Account Key <> GL A/c#  can be configured.