Use JEditorPane to display HTML and RTF ?

Hello,
Is it possible to use JEditorPane to open a HTML file and then save it as RTF?
And open a RTF file and save it as HTML ???
Eric

bump...
has anyone a solution to this?
I have a form that allows users to add raw HTML code. Now I want to display the formatted version in a report but the tags show in the report instead...any suggestions?
regards
Paul P

Similar Messages

  • Exception is thrown when using JEditorPane to display html

    Hello,
    I have this basic browser to display some pages from our intranet. Here's the code for it:
    import java.awt.BorderLayout;
    import javax.swing.JPanel;
    import javax.swing.JEditorPane;
    import javax.swing.JScrollPane;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.io.IOException;
    public class BrowserPanel extends JPanel {
    private JEditorPane pane = null;
    // Constructors
    public BrowserPanel() {
    pane = new JEditorPane();
    pane.setEditable(false);
    JScrollPane sp = new JScrollPane(pane);
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    setLayout(new BorderLayout());
    add(sp, BorderLayout.CENTER);
    // Methods
    public void setContent(String str) {
    StringBuffer sb = new StringBuffer(500);
    sb.append("http://local.com/cgi-bin/search.pl?arg=");
    sb.append(str);
    try {
    URL url = new URL(sb.toString());
    pane.setPage(url);
    } catch (MalformedURLException e) {
    System.err.println("Malformed URL: " + e);
    } catch (IOException e) {
    System.err.println("IOException: " + e);
    On some of the pages I get text all scrambled and the following exception comes up:
    java.lang.ArrayIndexOutOfBoundsException
    at javax.swing.text.html.TableView$RowView.layoutMajorAxis(TableView.java:1393)
    at javax.swing.text.BoxView.layout(BoxView.java:580)
    at javax.swing.text.BoxView.setSize(BoxView.java:265)
    at javax.swing.text.BoxView.paint(BoxView.java:283)
    at javax.swing.text.html.TableView$RowView.paint(TableView.java:1315)
    at javax.swing.text.html.TableView.paint(TableView.java:740)
    at javax.swing.text.BoxView.paintChild(BoxView.java:104)
    at javax.swing.text.BoxView.paint(BoxView.java:294)
    at javax.swing.text.html.BlockView.paint(BlockView.java:240)
    at javax.swing.text.BoxView.paintChild(BoxView.java:104)
    at javax.swing.text.BoxView.paint(BoxView.java:294)
    at javax.swing.text.html.BlockView.paint(BlockView.java:240)
    at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1170)
    at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:523)
    at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:657)
    at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:636)
    at javax.swing.JComponent.paintComponent(JComponent.java:395)
    at javax.swing.JComponent.paint(JComponent.java:687)
    at javax.swing.JComponent.paintChildren(JComponent.java:498)
    at javax.swing.JComponent.paint(JComponent.java:696)
    at javax.swing.JViewport.paint(JViewport.java:668)
    at javax.swing.JComponent.paintWithBuffer(JComponent.java:3878)
    at javax.swing.JComponent._paintImmediately(JComponent.java:3821)
    at javax.swing.JComponent.paintImmediately(JComponent.java:3672)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:370)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:337)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
    Many thanks for any clues on how to make it work.
    cheers,
    --JavanT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    you should specify that this is an HTML veiwer explicitly, by writting something similar to this,
    editor.setContentType("text/html");
    kit = (HTMLEditorKit) editor.getEditorKit();
    editor.setEditorKit(kit);
    doc = (HTMLDocument) kit.createDefaultDocument();
    editor.setDocument(doc);

  • Fail to use Jeditorpane to display a text with big5 encoding

    Hi All,
    I fail to use Jeditorpane to display a text with big5 encoding correctly.
    It only show machine code.
    I am using jre1.6.0_17. Yet it works well with earlier version of jre like jre 1.6.0_15, and jre 1.6.0_16
    bcpscsin

    bcpscsin wrote:
    ..I can find it in javax.swing
    FFS! It is JEditorPane, not Jeditorpane. Count the freaking upper case letters in both of those!
    Convince yourself by following these two URLs
    [http://java.sun.com/javase/6/docs/api/javax/swing/JEditorPane.html] -> produces a web page.
    [http://java.sun.com/javase/6/docs/api/javax/swing/Jeditorpane.html] -> "Page Not Found"
    My point is - do not type 'something like' the class name - get it right so we can be sure. Programming is a technical business and programmers need to be very accurate. It is even more important to be very accurate when asking for help on an forum. People have very little time to 'hold your hand' about the correct spelling and capitalisation of class names - or anything else for that matter.
    You still have not answered my question about the bug database.

  • HI, I am trying to connect my macbook pro,  18 months old, to a projector using the mini display port and a cable/connector to a VGA port on the back of the projector.  It all fits but the there is nothing happening? no mirroring option. Any ideas?

    HI, I am trying to connect my macbook pro,  18 months old, to a projector using the mini display port and a cable/connector to a VGA port on the back of the projector.  It all fits but the there is nothing happening? no mirroring option. Any ideas appreciated.  Many thanks

    to get to the Detect Displays button you have to hold down the Option key and the button appears.
    SeanfromFulham wrote:
    Many thanks, however I don't seem to have any relevant options under displays.

  • Open HTML and RTF in JEditorPane !!

    Hello,
    Is it possible to use JEditorPane to open a HTML file and then save it as RTF?
    And open a RTF file and save it as HTML ???
    Eric

    I tried. When the HTML or RTF contains TABLE, both will not recognize it. Is there any problem.
    I mean if the HTML contains TABLE, when I tried to write it to RTF, it will omit the table format. In the contrast, if the RTF contains the TABLE format, when I write the RTF to HTML, it also omits the table format.
    Eric

  • JEditorPane not Displaying HTML Correctly

    I have a section of code that needs to lookup the HTML for a given URL, and then store the HTML for future use. The problem is the HTML is displaying in the JEditorPane as text rather than rendering it as HTML.
    I've stripped the code down as much as possible to work this out. The code to set up the JEditorPane;
         jepLocal = new JEditorPane();
            jepLocal.setEditable(false);
            jepLocal.addHyperlinkListener(new LinkFollower(jepLocal));
            // these 2 lines set the jep for syncronous operation ...
            JEditorPane.registerEditorKitForContentType( "text/html", "HTMLEditorKit2" );
            jepLocal.setEditorKitForContentType( "text/html", new HTMLEditorKit2() );
            jepLocal.setPage(urlArray[0]);
    htmlString = jepLocal.getText();
    I'm using a simple class to set the jep into syncronous mode for retrieval. Here is that class;
    class HTMLEditorKit2 extends HTMLEditorKit{
      public Document createDefaultDocument(){
        HTMLDocument myDocument = (HTMLDocument)(super.createDefaultDocument());
        myDocument.setAsynchronousLoadPriority(-1); // load synchronously
        return myDocument;
      }The code runs in it's own thread, in case that matters.
    Can anyone see what is wrong with this setup? When I feed the htmlString into another jep, I get text display of the html rather than rendered.
    Bernie

    When I feed the htmlString into another jep, I gettext display of the html rather than rendered.
    How are you "feed[ing] the htmlString into another
    jep?" Does the other JEditorPane know it's text/html
    rather than text/plain?
                    myThis.getEditorPane().setText(htmlString);The other jep is in the main gui thread. It loades web pages fine when it's handed a URL and the extracted HTML can be saved and redisplayed using the setText method like above. This jep has all the same setup code, including the EditorKit inclusion.
    Bernie

  • Problem reading html and rtf emails

    When I send emails from my pc to my iPhone 5 in html or rtf format they are unreadable as all of the coding instructions are also included in the text when it appears on screen. This was never a problem with my iPhone 4 so I am not sure what has changed. I have a business contact who has had similar problems in the recent past with my emails so I know it is not just me.
    I have tried sending html emails from other pc's in the office to my phone and they are all readable so perhaps it is something in the set up of my pc that is causing this issue. As my office is changing over to iPhone 5's does anybody have any solution to what will become a very annoyinmg problem.
    Obviously I could send all of my emails in plain text but that doesn't really work for what I need to send, logo's / graphics etc.

    Hi
    The best way to organize data and images to get them next to each other is to use a table (no borders) in your RTF template. Create a two celled table and drop the image into one and the text next to it.
    Regards
    Tim

  • Working with JEditorPane to display HTML page

    iam loading html page into JEditorPane .
    how to get the html form data to validate
    give me soluation for this problem ...
    thanks ....
    karthi

    Search for occurences of <img> tags in the stream and replace its src="" contents by for example src="image?id=orginatingimagefilenameorso" and write kind of an ImageServlet mapped on "/image*" which streams the right images to the response.
    You may find this ImageServlet example useful: http://balusc.blogspot.com/2007/04/imageservlet.html
    After all, why are you streaming HTML files through a servlet instead of just linking to them? Aren't they public accessible or so? If this is the case, consider creating a virtual host on the application server so that you can just access those files through a simple plain vanilla URL.

  • Preview in firefox only displaying HTML and CSS code

    For some reason, when I go to preview my page in my browser (latest version of Firefox), I've been trying new things out from what I've been seeing at alt-web.com, and copying a lot of their code to experiment with is the only time I have this issue.
    Here is what is being displayed at the moment, along with the .css:
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- TemplateBeginEditable name="doctitle" -->
    <title>Untitled Document</title>
    <!-- TemplateEndEditable -->
    <!-- TemplateBeginEditable name="head" -->
    <!-- TemplateEndEditable -->
    <link href="../css/alt-style my footer.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
         <div id="headerWrapper">
              <div id="header_logo_over_links">
              </div>
         </div>
                        <div id="contentWrapper">
                        </div>
                   <div id="footerWrapper">
                   </div>
    </body>
    </html>
    @charset "utf-8";
    /* CSS Document */
    /** zeros out default browser settings for all page elements**/
    *{margin:0;     padding:0;     border:0;     font-size: 100%; line-height:100%;
    /**For non-IE browsers**/
    html,body {font-size:90%; height:102%; margin-bottom:1px;} /**adds scrollbar in Mozilla**/
    /**For IE only, you can move this to a Conditional Comment if you like**/
    *body {font-size:76%; zoom: 100%;}
    body {
         font-family:Verdana, Arial, Helvetica, sans-serif;
         width: 100%;
         min-width:1000px;/**not supported in pre-IE7**/
         text-align: center;
         background-color:#222222;
    /**Liquid Header**/
    #headerWrapper {
         padding:0 10px 0 10px;
         line-height:0;
         color:white;
         font-weight:bold;
         min-height: 85px; /**adjust to height of background image**/
         _height: 85px /**for IE6 only**/;
         background:url(../Images/Defaut%20Images/yellow_white_background__85px.jpg);
         #header_logo_over_links{
         position:absolute;
         margin-left:5px;
         margin-top:0px;
         width: 137px;
         height:77px;
         display:block;
         z-index:2;
         background:url(../Images/Defaut%20Images/resize_logo.gif) no-repeat
    .headRight {text-align:right;}
    #sidebar {
         float:left;
         width: 150px;
         overflow: hidden;
         margin:45px 0 0 0;
         padding:0;
         color: #FFF;
    #contentWrapper {
         width:700px; /**adjust width as needed**/
         background:#E5E5E5; 
         margin:0 auto; /**centers container on screen**/
    .content {padding: 10px; text-align: left
    /**begin Liquid Footer**/
    #footerWrapper {
         width:100%;
         background: #2175BC;
         line-height: 1.5px;
         color: #FFF;
         font-weight: bold;
         padding: 10px;
         text-align: left;

    Remove this line of code.  It denotes a .js page and I don't think that is what you want.
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • Use report to display html data

    Hi
    I have multiple rows of text in a clob field that contains html tags. I want to display this data in html format in my htmldb application. Can I use an htmldb report to do this or am I better off using an item?
    Thanks

    bump...
    has anyone a solution to this?
    I have a form that allows users to add raw HTML code. Now I want to display the formatted version in a report but the tags show in the report instead...any suggestions?
    regards
    Paul P

  • Plug-ins for viewing files such as .swfs and .rtfs in Finder's Preview Pane

    Are there plug-ins which would allow files such as .html and .rtf to display details of their content within the Finder's Preview pane, in a way similar to the way it is possible to preview .pdf, .txt, and .jpg files?
    thanks

    No, but any text editor can display html and rtf files, for example, TextEdit in your Utilities folder.

  • URGENT: JEditorPane (a Java Browser) displaying HTML form

    Hi,
    I am using JEditorPane to display the wb pages but geeting problem as
    I don't get any kind of event when I click on the HTML form SUBMIT button though it does work but didn't allow me to get the URL of the new page that I got after hitting this SUBMIT button..
    I searched the whole net and it seems to me that lot of people got this problem...
    As I need this for my project please HELP me as soon as possible.

    This may be too late for you (hopefully not), but I had the same problem a little while ago and just figured out how to fix it. Basically, you need to examine the Element structure of the html yourself and manually handle the form, as far as I can tell. There are several ways to display a URL in a JEditorPane, but the most straight-forward (JEditorPane.setPage(URL url)) doesn't actually store the Element structure anywhere accessible. Here's the code to load the page:
    JEditorPane contents;
    HTMLEditorKit kit = new HTMLEditorKit();
    HTMLDocument htmlDoc = new HTMLDocument();
    contents.setEditorKit(kit);
    contents.setDocument(htmlDoc);
    URL url = new URL("http://blahblahblah.com");
    contents.read(url.openStream(), htmlDoc);Now that you have the page loaded correctly, you can access to the Elements within. You can use htmlDoc.getDefaultRootElement() to get the root and then iterate recursively through all the child Elements, checking out the Attributes of each. This will look for the submit button and add a listener to it for you:
    private void parseElements(Element elem) {
        AttributeSet atts = elem.getAttributes();
        //If this is the submit button, add a listener:
             Object model = atts.getAttribute(StyleConstants.ModelAttribute);
             Object type = atts.getAttribute(HTML.Attribute.TYPE);
             if ((type != null) && (type.equals("submit"))) {
                 DefaultButtonModel btn = (DefaultButtonModel) model;
                 btn.addActionListener(new ActionListener() {
                     public void actionPerformed(ActionEvent event) {
                         System.out.println("Yay!");
        //Recurse
        for (int i = 0; i < elem.getElementCount(); i++)
             parseElements(elem.getElement(i));
    }Of course, printing out "Yay!" is not really very helpful. When you're parsing through the Elements, check for the attribute StyleContsants.ModelAttribute. If that exists, you can cast it to the correct type of Model (see the documentation for HTMLDocument.HTMLReader.FormAction for information about what types of models to expect from what types of HTML elements) and store it until the "submit" button is pressed. Then all you have to do is get all the data from the models, format it and submit it to the action URL in either a "get" or a "post." The action URL is stored, in Java 1.3, in the HTML.Tag.Form attribute of one of the Elements (I don't remember which one). Getting that attribute returns a SimpleAttributeSet, and you get the HTML.Attribute.Action out of that. In Java 1.4 it's easier to find, you just have to look for the HTML.Attribure.Action attribute in one of the Elements.
    Why isn't this all automatically done for you? I don't know. Good luck.
    -Nathan

  • JEditorPane doesn�t display HTML special char. codes

    My application is using JEditorPane to display text/html.
    The problem comes when I try to display HTML special character codes such as
    &gt; JEditorPane ignores those codes and displays nothing.
    Do I have to convert all those strings representing special characters?
    How could I solve it?
    Thanks in advance,
    Bruno

    Here's my solution - I replace the HTMLEditorKit if it's not the first pass through. I found that the EditorKit is an instance of HTMLEditorKit for every pass except the first (which doesn't have a problem).
    EditorKit ek = displayJEditorPane.getEditorKit();
    if( ek instanceof HTMLEditorKit ) {
         // Needs to be replaced
         HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
         displayJEditorPane.setEditorKit( htmlEditorKit );
    // Display the HTML document
    displayJEditorPane.setPage( resultURL );I'll spread my Duke Dollars around to everyone who offered a suggestion later today if I don't hear of a better solution.
    Thanks.

  • Problem in html and using javascript

    Hello,
    I want to create a html page that calls a javascript file(.js) using the HTML portlet. The problem is that i do not how to specify the location of the javascript (src="location/name of .js file")as i do not know in which directory does the HTML portlet resides.
    Please give me some guidance on this.
    Thanks in advance.

    If you want to store the .js file on the file system, the base directory is <ORACLE_HOME>/portal. For example, on Windows, if your mid-tier Oracle Home is d:\iasv2, your base directory will be d:\iasv2\portal. The relative link "/location/myjs.js" (note the leading slash) would resolve to "d:\iasv2\portal\location\myjs.js".
    If you want to store the file in the Portal repository, the path is "/<DAD>/docs/PAGE/<pagepath>/<docname>", where <DAD> is your database access descriptor (e.g."/pls/portal"), <pagepath> is the path to the page on which the document is stored, starting with the name of the root page of the page group. So if your DAD is "/pls/portal", your root page is called "mypages" (the internal name is used, not the display name), and the document is stored on a page under the rootpage called "myscripts", the href will be "/pls/portal/docs/page/mypages/myscripts/myjs.js".
    You can also specify a path relative to the current page. So, in the above example, if your HTML portlet is on "mypages", your href can be simply "myscripts/myjs.js".
    If this is release 1 of Portal (3.0.x), use /<DAD>/docs/FOLDER/<folderpath>/<docname> as the path to the document (e.g. "/pls/portal/docs/folder/myfolders/myscripts/myjs.js").
    Regards,
    Jerry
    PortalPM

  • Using a PowerPc G5 and Mac Mini with the same display, keyboard and mouse

    I have a G5 PowerPC and a new Mac Mini. I wanted a good KVM switch so that I can use the same display, keyboard and mouse with both machines. Any suggestions?

    IOGear, Trendware and Startech.
    I'd stick with IOGear.

Maybe you are looking for

  • Erro de Validação SCS = 9

    Bom dia pessoal, tudo bem? Estamos atualizando a NFE 2.0 no ambiente QAS. Após a geração da NFE, retornou o status para J1BNFE da seguinte forma: - status ação: em comunicação (rodinha) - log NFE: verdinho - status do documento: branco - status de co

  • QT 7.1: App itself and iTunes wont launch anymore

    i have updated QT 7.xx to 7.1 on a 10.3.9 this morning. now QT and iTunes won't launch no more. there is no warning or anything, but the programm windows wont open. HELP please.

  • How to migrate my-sql into ORACLE!

    I have this database running in my-sql. nOw i want to convert into ORACLE.Can anyone shed light on this please..does sql loader support this? Thanks in advance..your help will be much appreciated.. ashish

  • Setting to delete played podcasts?

    Is there a setting I can make on iTunes for my Nano where it will automatically delete the podcasts I've already listened to from the iPod when I sync it? It's annoying to me to have to go back in to iTunes and delete the podcasts I've already listen

  • Backup Smart Collections

    Hi, Is there a way to export the smart collections and import them into another catalog? http://dl.dropbox.com/u/1924024/smart_collections.jpg BTW, where does Lightroom store the smart collections? I'm unable to find them in the /Library/Application