DefaultStyledDocument in detail? / Illegal cast to MutableAttributeSet

Hi Developers,
I got some questions about javax.swing.text.DefaultStyledDocument.
* Is it possible to use DefaultStyledDocument with own implementations (say MyElement) of the Element interface?
MyElement implements Element, AttributeSet and MutableAttributeSet (just like AbstractDocument.AbstractElement) but not AbstractDocument.AbstractElement itself. Most of the public and protected methods of DefaultStyledDocument use interface-types, only the method createDefaultRoot returns an AbstractDocument.AbstractElement. As far as I see, this method is called in the constructor in DefaultStyledDocument.
* Does anyone know what exactly happens in the constructor? Then I could implement my own constructor that does not use the createRootElement method, but a corresponding one that returns of type MyElement?
* Does DefaultStyledDocument really need Elements of type AbstractDocument.AbstractElement for other operations?
Background: Why not use an inheritant of AbstractDocument.AbstractElement?
I'm working on a collaborative authoring tool that uses a groupwareframework (DyCE of GMD Darmstadt). In this framework, every Object that should be replicated must inherit of a special objecttype. Thus I cannot inherit of any other class like AbstractElement.
* Has anyone detailed information about DefaultStyledDocument especially how it works internally?
* Has anyone ever experienced the errormessage: javax.swing.text.StateInvariantError: Illegal cast to MutableAttributeSet
     at javax.swing.text.AbstractDocument$AbstractElement.checkForIllegalCast(AbstractDocument.java:1653)
and knows what I have done wrong?
* If this one will not work: Does anyone have information about ElementBuffer and ElementSpec (I've already read the ElementBuffer atricle on the swing connection)
* Is there anyone who has some experience on DefaultStyledDocument and can advise me to skip this whole DefaultStyledDocument-thing and reimplement the StyledDocument interface?
I need all this stuff for my Diplomarbeit (master thesis) in computer sciences which I study at the Frankfurt university, Germany.
Thank you veryvery* much in advance,
     Laura Dietz

Has anyone ever experienced the errormessage: >javax.swing.text.StateInvariantError: Illegal cast to
MutableAttributeSet
at >javax.swing.text.AbstractDocument$AbstractElement.ch
eckForIllegalCast(AbstractDocument.java:1653)
and knows what I have done wrong?The above exception is thrown whenever u atempt to do the following thing:
*After setting the content type as "text/html" ,and u try invoke the method
1)insertComponent()
2)insertString()

Similar Messages

  • JEditorPane POST [1.5.0]

    Hi out there!
    I use a JEditorPane to POST data in an HTML form. With Java 1.4.2 (Linux) everything works fine. The same code however, using Java 1.5.0 (Linux) doesn't work any more: The CGI script does not receive any of the posted data.
    I don't have any ideas, since the pressing of buttons in a JEditorPane is handled internally by JEditorPane, I don't know how to influence its behaviour. Any ideas how to fix this problem? Or what am I doing wrong?
    Thanks for your help,
    Nicolas Michael

    Some additional information: I wrote a little test program:
    import java.awt.*;
    import javax.swing.*;
    public class JEditorPaneTest extends JFrame {
      JEditorPane pane = new JEditorPane();
      public JEditorPaneTest() {
        try {
          pane = new JEditorPane();
          pane.setEditable(false);
          this.getContentPane().add(pane, BorderLayout.CENTER);
          pane.setPage("http://www.nmichael.de/efaWett/drv/einsenden.html");
        catch(Exception e) {
          e.printStackTrace();
      public static void main(String[] args) {
        JEditorPaneTest frame = new JEditorPaneTest();
        frame.show();
    }Using Java 1.4.2 it works fine, but with Java 1.5.0 I get the following exception when clicking on the button in the HTML form:
    Exception in thread "AWT-EventQueue-0" javax.swing.text.StateInvariantError: Illegal cast to MutableAttributeSet
    at javax.swing.text.AbstractDocument$AbstractElement.checkForIllegalCast(AbstractDocument.java:2055)
    at javax.swing.text.AbstractDocument$AbstractElement.removeAttribute(AbstractDocument.java:2000)
    at javax.swing.text.html.HTMLDocument.updateFrame(HTMLDocument.java:623)
    at javax.swing.text.html.HTMLDocument.processHTMLFrameHyperlinkEvent(HTMLDocument.java:517)
    at javax.swing.text.html.FrameView.hyperlinkUpdate(FrameView.java:307)
    at javax.swing.JEditorPane.fireHyperlinkUpdate(JEditorPane.java:320)
    at javax.swing.text.html.FormView$SubmitThread$1.run(FormView.java:477)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Any ideas?
    Thanks,
    Nick

  • Code highlighting?

    Hi,
    I am writing a simple IDE editor as an example for a plugin engine.
    I want to add code highlighting, but I get an exception when I try to do this (I want to change the color and the style(to bold)).
    Exception occurred during event dispatching:
    javax.swing.text.StateInvariantError: Illegal cast to MutableAttributeSet.
    I am doing this in the method keyReleased (from KeyListener).
    Any one has a sollution for this?

    I'm doing this without modifying the contentType, on a JTextPane :
              try
                   SimpleAttributeSet attrib;
                   attrib = new SimpleAttributeSet ();
                   attrib.addAttribute(StyleConstants.Background, Color.BLUE);
                   attrib.addAttribute(StyleConstants.Foreground, Color.YELLOW);
                   if (annulation != null)
                        attrib.addAttribute(StyleConstants.Foreground, Color.RED);
                   attrib.addAttribute(StyleConstants.Bold, new Boolean(true));
                   document.remove(start, source.length());
                   document.insertString(start, change, attrib);
              catch (BadLocationException e)
                   e.printStackTrace();
              }.. Could you please poste the part of code where the error throw ?
    JMS.

  • How to cast a String input into Date variable?

    I am using JOptionPane.showInputDialog to ask user for a date input. This will be read in as a String. I need to pass it to a variable call date. And when I print date using JOptionPane, it should be shown as whatever the user keyed in in this format: 25/2/09. How do I do it?

    By the way, that's not casting. Casting is when you have a variable whose type is at a particular level of detail, and you assign it a different level of detail -- say, casting an int to a long, or a List to an ArrayList.
    What you want to do is convert one type to a completely different one. In particular, you're going to do that by using SimpleDateFormat to parse the String -- that is, SimpleDateFormat will read the string, pick out the individual parts that express the date, and create a Date object that corresponds to it.

  • Some app haveavery hard to read detail what u see on App Store and netflix too

    Hi I have use App Store and pick want to see read detail about apps that I read so small hard to read this! I which that let detail to change size text too also on Itune store and amazon and apple store also netflix too man I have to get close ipad to read gee that abrass!
    I have low vision I need comfort to read detail and cast and information about apps and others too so please send this apple developer and tech too.  Thanks I need keep my eyes stress down. Why can this accessibility too add detail to read better!

    Go to settings> general> accessibility> zoom> turn on. Now if you can't read the app description double tap the screen with three fingers. Double tap the screen with three fingers to return to normal size.

  • Legal casting in generics

    I'm migrating from 1.4 to 1.5 and have a question about when casting is legal (and workable) in generics. After reading various literature, it seems that erasure removes type information at run time. Yet casting does seem to work. Here is the source of min() in Collections class -
        public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) {
            if (comp==null)
                return (T)min((Collection<SelfComparable>) (Collection) coll);
    .....Obviously this code works. If erasure removes type info, how do the casts above work?
    More generally, when is casting to generic types allowed and succeed in 1.5 and above?
    And also I'm curious if the compiler generated any unchecked message on this piece of code (I don't see any suppresswarning tag in the source).
    Thanks

    Obviously this code works. If erasure removes type info, how do the casts above work?A generic call is replaced with explicit casts by the compiler:
    public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) {
    // becomes (generic type is erased)
    public static Object min(Collection coll, Comparator comp) {
    Number minimum = min(new ArrayList<Number>(), null);
    // becomes (explicit cast added)
    Number minimum = (Number) min(new ArrayList(), null);
    More generally, when is casting to generic types allowed and succeed in 1.5 and above?It is allowed, but it is always an "unchecked" warning. Note that the generic cast is erased, so it can't succeed or fail.
    The explicit cast that the compiler adds (in this case when the method is called) can fail if there are unchecked warnings.
    Note that if a generic is bounded, the generic cast is erased to the bounds (if <T extends Number> then (T) will be (Number), but if that is an illegal cast you get an compiler error:
    // eclipse compiler will also complain Double is final and cannot be extended.
    public <T extends Double> T min(String arg, Number arg2) {
      // error: Cannot cast from String to T
      Double error = (T) arg;
      // warning: Type safety: The cast from Number to T is actually checking against the erased type Double
      // aka it might be an Integer
      Double warning = (T) arg2;
    }

  • Error while using parsleyframework in flex

    Hi,
      i am getting below error whilr running flex application in parsley framework .
    Error Details:
    Illegal override of ModuleInfoProxy in FlexModuleSupport.as$348.ModuleInfoProxy.
    param count mismatch
    param count mismatch,birt params=2 optional=2 mx.modules::IModuleInfo/mx.modules:IModuleInfo::load()
    Please help me

    Hmm, thanks Flex HarUI... IU I kinda think the boffins at Adobe are less likely than me to have the problems.
    I'm going to attach the swf and it's associated .fla if that is any more help.
    For the record this is the Error Message:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at flash_component_fla::MainTimeline/frame1()
    Any help would be hugely appreciated...

  • What is the correct way to add styling to drag-and-drop created calendars?

    I have a working instance of a rich client calendar. I generated the view with the required fields (start, stop, provider, ...), put it into the App Module, and dragged it onto a JSF page to create a calendar.
    Next I created an activityScope object in a class called CalendarBean (no inheritance)
    Class CalendarBean()
    private HashMap<Set<String>, InstanceStyles> activityColorMap;
    +..+
    +public CalendarBean() {+
    super();
    activityColorMap = new HashMap<Set<String>, InstanceStyles>();
    HashSet setEd = new HashSet<String>();
    HashSet setLen = new HashSet<String>();
    setEd.add("Work");
    setLen.add("Home");
    activityColorMap.put(setEd, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.ORANGE));
    activityColorMap.put(setLen, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.RED));
    +}+
    +}+
    Next, I linked this up as a backing bean and associated the ActivityStyles of CalendarBean to it:
    +#{backingBeanScope.calendarBean.activityColorMap}+
    I populated some records in the database with properties "Work" and "Ed', but they show default blue.
    As I understand it, I need to do something with the getTags() method of the underlying CalendarActivity class, but I'm not quite sure how to do that.
    Took a stab at creating a class, CalendarActivityBean, that extended CalendarActivity, and pointed all the CalendarActivity references I had to the new class, but it didn't seem to fire (in debug), and I got into trouble, when inserting records, with
    public void calendarActivityListener(CalendarActivityEvent calendarActivityEvent) {
    currActivity = (CalendarActivityBean) calendarActivityEvent.getCalendarActivity();
    being an illegal cast
    What is the correct way to add provider-based styling to drag-and-drop create calendars?
    Ed Schechter

    A colleague of mine was kind enough to solve this:
    The calendar has ActivityStyles property = #{calendarBean.activityStyles}
    CalendarBean looks something like this:
    package com.hub.appointmentscheduler.ui.schedule;
    import java.util.HashMap;
    import java.util.HashSet;
    import java.util.Set;
    import oracle.adf.view.rich.util.CalendarActivityRamp;
    import oracle.adf.view.rich.util.InstanceStyles;
    +public class CalendarBean {+
    private HashMap activityStyles;
    private String dummy;
    +public CalendarBean() {+
    +// Define colors+
    activityStyles = new HashMap<Set<String>, InstanceStyles>();
    HashSet setPending = new HashSet<String>();
    HashSet setArrived = new HashSet<String>();
    HashSet setApproved = new HashSet<String>();
    HashSet setCompleted = new HashSet<String>();
    setApproved.add("APPROVED");
    setPending.add("PENDING");
    setArrived.add("ARRIVED");
    setCompleted.add("COMPLETED");
    activityStyles.put(setApproved, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.GREEN));
    activityStyles.put(setPending, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.ORANGE));
    activityStyles.put(setArrived, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.PLUM));
    activityStyles.put(setCompleted, CalendarActivityRamp.getActivityRamp(CalendarActivityRamp.RampKey.LAVENDAR));
    +}+
    +public void setactivityStyles(HashMap activityStyles) {+
    this.activityStyles = activityStyles;
    +}+
    +public HashMap getactivityStyles() {+
    return activityStyles;
    +}+
    +}+
    Now, go into the Bindings tab on the calendar page, double click the calendar binding, and specify the column you've defined as the calendar's Provider in the Tags dropdown.
    Should show colors.

  • SOAP Adapter Sender PI7.1: 400 Bad HTTP request

    Hello,
    I have a problem with a SOAP adapter sender communication channel.
    I'm trying to migrate a scenario from XI 3.0 to PI7.1 SP6 (PI_BASIS 2006_1_710 SAPKIPYN06).
    I can send messages successfully to the old system using the URL
        http://host:port/XISOAPAdapter/MessageServlet?channel=:BC_Name:CC_SOAP_Sender
    On PI7.1 I get
        400 Bad HTTP request
        Error: -21
        Version: 7010
        Component: HTTP_PLG
        Module: http_plgrt_mt.c
        Line: 5226
        Error Tag:
        Detail: illegal request version
    I have created a Sender Agreement, generated the wsdl from that and tried the URL in there.
    Surprisingly it has the old format, namely
        http://host:port/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_Name&receiverParty=&receiverService=&interface=myInterface&interfaceNamespace=urn:my.Interface:ns
    although the 7.1 documentation describes the ?channel=party:service:channel style only.
    Anyway, the result remains the same.
    I tried some other approaches like escaping the colons in the URL without success.
    The user has the role SAP_XI_DEVELOPER_J2EE assigned.
    Any idea what's wrong here?
    Thanks in advance
    Rainer

    >>In RWB the channel appears as "started but inactive".
    Yeah,it will be like that because you are posting messages directly to Integration server."Propose URL" does that.You are bypassing the adapter engine when you use the URL generated by "Propose URL" button.
    /people/stefan.grube/blog/2006/09/21/using-the-soap-inbound-channel-of-the-integration-engine
    The above blog gives the reason for this,if you want to bypass the adapter engine,then generate the URL as given in the above blog
    /people/siva.maranani/blog/2005/03/01/testing-xi-exposed-web-services
    This blog explains how to post message to adapter engine,here you need to change the URL,don't click on "Propose URL" button.You can monitor SOAP adapter in RWB only if you generate the URL as given in second blog
    The URL which is working for you in XI 3.0 is posting messages to adapter engine,so generate the URL in PI 7.1 in the same way,by following the second blog i have mentioned.
    Thanks
    Aamir

  • Limit on items in shopping cart

    I am trying to determine if there is a limit on the number of items in the shopping cart coming back from the catalog.  We use SciQuest and when a user transfers her items back to SRM, she is getting an 400 Bad HTTP request.  There are 60 lines on the cart in the catalog.  I don't think the issue is on the SciQuest side, but something in the translation coming back to SRM.
    400 Bad HTTP request
    Bad HTTP request
    Error:  -21
    Version:        7000
    Component:      HTTP_FILTER
    Date/Time:      Mon Sep 12 13:06:05 2011
    Module: http_auth_mt.c
    Line:   494
    Server: olympia_PEP_43
    Error Tag:     
    Detail: illegal request

    If that is caused exceeding by the maximum size (4096) for a cookie then there is nothing to do about it.
    * http://mxr.mozilla.org/mozilla1.9.2/source/netwerk/cookie/src/nsCookieService.cpp#94
    * http://mxr.mozilla.org/mozilla1.9.2/source/netwerk/cookie/src/nsCookieService.cpp#1435

  • Page display:400 Bad HTTP request after implement WebDispatcher fo portal

    Dear all
       Our portal implement the WebDispatcher(7.0) to load balance for our
    portal system(include one CI and one Dialog instance,we use HTTP to
    load our portal request.).After that,some of the portal page display
    the information like this:
    400 Bad HTTP request
    Bad HTTP request
    Error: -21
    Version: 7000
    Component: HTTP_FILTER
    Date/Time: Thu Sep 27 10:26:51 2007
    Module: http_auth.c
    Line: 469
    Server: portal_WDP_02
    Error Tag:
    Detail: illegal request
    &copy; 2001-2005, SAP AG
    We logon the CI and the page all are right.So,some wrong with our
    WebDispatcher?Can you give us some advice?

    Hi,
    The answer from SAP:
    The maximum size of request URI is hard coded in kernel, and it cannot be configured by a parameter. The maximum size of PATH is 4096, and the maximum size of query string is 4096 as well.
    If the request is a post request, you have to ask the calling side to move some name value pairs from query string to the POST body.
    If it is a GET request, you have to ask the calling side to change it to POST and move value pairs to the POST body.
    Kind Regards

  • PI Soap receiver channel calling a Soap Sender channel

    Hi,
    I had  scenario where One pi711 interface need to be called by another interface in PI711.
    whole designed is like.
    file ->  PI1 ->Soap  ->  Soap ->PI2 ->  file.
    P1 and P2 are two different interfaces in one PI711 box.
    could  Soap receiver communication channel  can call a Soap sender communcation channel  of another interface.
    does HTTP or Soap (XI3.0 protocal) is helpful......
    regards,
    Swat

    Hi,
    I am receiving an error as :-
    400 Bad HTTP request
    Error: -21
    Version: 7011
    Component: HTTP_PLG
    Date/Time: Mon May 24 06:58:32 2010 
    Module: http_plg_mt.c
    Line: 5417
    Server: xxx_XD2_02
    Error Tag:
    Detail: illegal request version
    This details error log is taken using TCPgw application downloaded from service marketplace, since in CC monitering error details was too short to investigate..
    refered :
    /people/stefan.grube/blog/2007/03/29/troubleshooting-soap-http-and-mail-adapter-scenarios-with-tcpgateway
    the url which i used in P1 receiver Soap channel  to connect to soap sender cc is  :-
    http://xxx:51000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BCSender2&interface=OutS_SI&receiverParty=&receiverService=BC_Receiver2&interfaceNamespace=http://icc/Test1
    Regards,
    Swati

  • Post-mapping process error

    I have built all of my process in v9.0.2.62.3 except for once the row is loaded into my staging table, I want to delete this row from the source. I was trying to use the post-mapping process to call a procedure that would perform the deletion. However, I can not get the post-mapping process to work.
    The manual states to add a post-mapping process operator to a mapping:
    Drop a Post-Mapping Process operator onto the Mapping Editor canvas.
    Select the appropriate procedure from the selection list. This were I select a procedure called drop_ind with one input parameter, v_ind_id, of type number.
    Connect the output attribute of a source operator to the INOUTGRP1 of the Post-Mapping Process operator.
    This is where things start to go wrong with the manual. There is no INOUTGRP1, but only an INPUTS. If I try and attach the target column to the INPUTS, I get an API8009 cannot add attributes to POSTMAPPING INPUTS error. So I attach my target column directly to the input parameter
    Rename the operator:
    This goes well enough.
    Then I try and validate, and I get the following message wehn I try to generate the mapping :
    Code cannot be generated.
    Specify another operating mode or see validation messages for details.
    When I validate I get :VLD-2451 Illegal connection to POSTMAPPING. details = Illegal connection to POSTMAPPING.
    Obviously, I am doing something wrong, but what?

    Matthew,
    First a question, what are you trying to add to the post mapping process? The ID of the single row that is processed?
    In that case, you will have to rethink the strategy. What happens in a post map process (and the rest of the map) is the following:
    1) execute any pre mapping processes
    2) execute the main body of the mapping (this is you diagram excluding pre and post mapping processes)
    3) execute the post mapping process
    This means that the post mapping process will be run whenever the rest of the mapping is complete.
    So to do what you want, you can use the post mapping process but you would add a marker to every inserted record and then in the post map procedure delete all the ones that have this marker in the target from the source.
    In that case you would need any parameters from your map into the procedure and you should be all set.
    Hope this helps,
    Jean-Pierre

  • How to update Biztalk consumed WCF service in biztalk

    Hello All,
    I have consumed WCF service in BizTalk using BizTalk WCF Service Consuming Wizard by -> ADD -> Add Generated Item option.
    This created few Schema files and one orchestration.
    Now the other team made changes in datatype on two field from int to string.
    how to update this BizTalk Consumed WCF service to reflect these changes ?
    Thanks,
    Nilesh
    Thanks and Regards, Nilesh Thakur.

    Hold on!
    Are you sure they only changed the data type on two fields? If so, all you need to do is change the type in the schemas you already have. For such a small change, you don't need to regenerate.
    Also, if that's the only change, they type setting on two fields, you should not get any Map or Orchestration Errors. Well, you might get an illegal cast error of one of those fields is Distinguished and you doing an assignment in an Expression Shape.
    Also, keep in mind, the Schemas are the only really useful things created by the Wizard, I have never used the Orchestration, it's just a Port Type definition.  So, you can always generate into a new Project and compare/replace the Schema.  So
    long as you keep the .Net Type Name, you should be ok.
    If you are still getting Map and Orchestration errors, then they changed much more than two field types.  If you post the actual errors, we can provide some guidance.

  • ClassCastException on getObject()

    I'm using the thin driver Oracle JDBC 8.1.5. When I execute the
    following syntax:
    callStmt.registerOutParameter (1, java.sql.Types.INTEGER);
    callStmt.execute(); //correctly executed
    Object value = callStmt.getObject(1);
    Integer pk = (Integer) value; // Throws illegal cast exception
    The callable statement is executed correctly however the cast
    statement generates a "java.lang.ClassCastException:
    java.math.BigDecimal" error. If I replace the (Integer) cast with
    (java.math.BigDecimal) cast it works fine. What am I doing wrong?
    Pam Ross
    China Lake
    null

    The solution was to delete every ".adf" directory and adf-config.xml and adfm.xml that is contained in the workspace directory.

Maybe you are looking for

  • "File file path:to:file is already open" how do i close it?

    I am trying to write a script that pops up a dialog box, asks for text and saves this to a .csv and a .txt This is so i can quickly record what i am doing and the times i am doing it, makes quick notes and various things like that. However it is fail

  • How To Consume UME services in Web Dynpro applications

    Dear Friends, I am developing a new web dynpro application in which i want to get the user related information in my dynpro code. I have used com.sap.secuirty.jar file in class path -> lib of my project. I have written code sth like this. IUser user

  • No TEAC cd/dvd driver for Satellite A105 2101 not available???

    I have looked everywhere for a driver to replace my Missing or Corrupted (code 39) TEAC DW-22-224E-C driver for my Satellite A105 series!  I uninstalled and reinstalled the driver, and I have the latest update.  It is still not working - i get a code

  • Help needed with iTouch not appearing as a hard drive ?

    Hi all,  I need some important data that I had saved in my itouch as disk drive.  Usually when I plug my itouch into pc, it will auto-play on windows and will show it as disk drive. It will also auto-sync to my itunes. I can also find the disk drive

  • Using iPad charger w/ iPhone 3GS

    Is it safe to do so? I'd like to carry only one charger.