Regarding displaying html page in a JEditorPane

i want to display a html page in a JEditorPane but the problem is it is displying the page but the script part of html page is printed as it is in the pane . please tell the solution for it . i will be highly thankful to u.

What you are doing exactly? you are displaying the html file into a JEditorPane or After displaying you are tring to Print it out in the Paper or what.
If this the First Sinario then this code will help you.
import javax.swing.*;
import java.awt.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.*;
import javax.swing.text.*;
import javax.swing.event.*;
public class Htmlexample extends JInternalFrame {
     //Constructor of Class.
     public Htmlexample () {
          //super(Title, Resizable, Closable, Maximizable, Iconifiable)
          super (title, true, true, true, true);
          setSize (500, 350);
          HtmlPane html = new HtmlPane ("Help/Keys.htm");     
          setContentPane (html);                    
          setVisible (true);
//Following Class Show HTML Help inside an EditorPane.
class HtmlPane extends JScrollPane implements HyperlinkListener {
     JEditorPane html;
     public HtmlPane (String filename) {
          try {
               File f = new File (filename);          
               String s = f.getAbsolutePath();          
               s = "file:" + s;
               URL url = new URL (s);               
               html = new JEditorPane (s);          
               html.setEditable (false);          
               html.addHyperlinkListener (this);
               JViewport vp = getViewport();     
               vp.add (html);                    
          catch (MalformedURLException e) { }
          catch (IOException e) {     }
     //Function Perform By the HyperLinks of HTML Help File.
     public void hyperlinkUpdate (HyperlinkEvent e) {
          if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
               linkActivated (e.getURL());
     //Function for Loading other HTML Pages in Your HTML Help.
     protected void linkActivated (URL u) {
          Cursor c = html.getCursor();
          Cursor waitCursor = Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR);
          html.setCursor (waitCursor);
          SwingUtilities.invokeLater (new PageLoader (u, c));
     //Following Class Load Other Pages Included in Our HTML Help File.
     class PageLoader implements Runnable {
          //Constructor of Class.
          PageLoader (URL u, Cursor c) {
               url = u;
               cursor = c;
          public void run () {
               if (url == null) {
                    html.setCursor (cursor);
                    Container parent = html.getParent();
                    parent.repaint();
               else {
                    Document doc = html.getDocument();
                    try {
                         html.setPage (url);
                    catch (IOException ioe) {
                         html.setDocument (doc);
                         getToolkit().beep();
                    finally {
                         url = null;
                         SwingUtilities.invokeLater (this);
          URL url;
          Cursor cursor;
}if there is any other issue Let me Know
Thank you
Jofin

Similar Messages

  • Problem in displaying html page in JEditorPane....

    Hi All,
    i was trying to display a html page in a JEditorPane. i was able to do that when i'm displaying a html page from a local machine.. But when i try to get the page from some website, it giving me
    "exception access denied (java.net.SocketPermission www.java.sun.com resolve)"
    exception. But if i run the same code thru JBuilder, its working. But thru appletviewer or thru IE or Netscape its throwing the error.. Any suggestion or help is highly appreciated....
    Thanks
    Ragu

    Java Applets are very secure, what is good. Java applets are extremely secure
    what is bad. So Applet cannot open TCP connection to any host rather than its
    home host. So you cannot get the resources from any other server (what is common to
    HTTP).
    In JBuilder iit works cause JBuilder is used for development and security in deevelopment
    is not an issue. But it confuses then you see.
    vpanasenko_even

  • Displaying HTML page when server is unavailable

    Hi,
    I would like to display the static html page when the server is down. For example when server maintanance is going on I would like to display html page with information
    Please let me know what is the process to achive this.
    Thanks

    You might also want to check Custom Error pages:
    http://help.sap.com/saphelp_nw70/helpdata/EN/9a/e74d426332bd30e10000000a155106/frameset.htm
    Regards,
    Siddhesh

  • Can I display html pages in flash player

    Hi all,
    Can I display html pages in flash player, i mean swf. Plz
    help me if it can be done. Can I call html pages in flash (i mean
    in flash player no new window)
    Thanks

    hi,
    Actullay i want the site to be opened with in the flash
    player, just like iframe in dreamweaver calling the external site
    in the mail html page. Plz Help me accessing external site page
    with in flash player
    Thanks

  • How to display HTML pages always in first rank in search result?

    I have a sharepoint 2010 site where search is configured, but when it is displaying the search result some time it is  showing the pdf files  in the first order and the html pages in the second order, I need to display html pages always
    in the first order.How can I accomplish it?

    Alex's link is by far the best one but this is an alternative if you wanted to read a bit more widely
    http://sharepointkaos.wordpress.com/2011/01/13/custom-ranking-model/
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • I am using IFrame and displayed Html page

    Hi Friends
                        I am using IFrame and displayed Html page in flex4
                        In this page open to Firefox But not IE please help me.
                          Thanks
                           V.ChandraSekhar

    You have deleted your page, but you have not deleted your page?
    Which is it?
    If you never saved it it is gone. If you saved it in Lion (OSX 10.7) with Pages 09 v4.1, there should be versions available when you mouse overv the document name at the top of the window.
    Peter

  • 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.

  • Displaying html page with in the applet

    I want to open an html page in the applet. If i use showDocument() of applet, it opens the html page in the browser, but i want to open the html page with in the applet(i.e., applet should display the html page). Is there any way which i can do the above thing.
    Thanks in advance

    Look at this sample:
    import java.awt.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.text.*;
    public class BrwsA extends JApplet
         JPanel      jpa = new JPanel();
         JEditorPane jed = new JEditorPane();
         JScrollPane jsp = new JScrollPane(jpa);
    public BrwsA()
         jpa.setLayout(new BorderLayout());
         jpa.add(jed);
         jpa.setPreferredSize(new Dimension(800,1000));
         jed.setEditable(false);
         jed.setContentType("text/html");
         jed.getEditorKit().createDefaultDocument();
         setContentPane(jsp);
    public void init()
         try
              URL url = new URL(getCodeBase(),"test.html");
              jed.setPage(url);
         catch(MalformedURLException e)
         catch(IOException e)
    }Noah

  • Displaying HTML page from JFrame

    Hi ,
    I have a JFrame GUI with menus and menu items. After Clicking on the Help Menu Item, I want to display a HTML page. Does anyone know of a function to display an HTML page?

    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    // This class is used in the Image Tool class when the help menu item is selected
    public class HelpMenu extends JInternalFrame implements HyperlinkListener{
    // A new JEditorPane to display the help html file in.     
    private JEditorPane jep;
         public HelpMenu () {
              super("Help Menu",
                        true, //resizable
                        true,     //closable
                        true,     //maximizable
                        true);     //iconifiable
              // Set the size and location of the frame
              setSize(500,500);
              setLocation(20,20);
              // create the JeditorPane
              jep = new JEditorPane( );
         jep.setEditable(false);
              // Make jep a scrollable pane
              JScrollPane jsp = new JScrollPane(jep);
         getContentPane( ).add(jsp, BorderLayout.CENTER);
              // Add a listener to listen for hyperlinks within the document
         jep.addHyperlinkListener(this);
         try {
         String HelpFile = "file:C:/Documents and Settings/Patrick/Desktop/Help.html";
         jep.setPage(HelpFile);
              // If the file can be loaded display the frame
              setVisible(true);
         catch(Exception e) {
              // The file could not be loaded.
              System.out.println(
                   "Could not open help page! Has it been deleted from: C:/Documents and Settings/Patrick/Desktop/");
              // If the file can not be loaded display an error message
              JFrame f = new JFrame();
         JOptionPane.showMessageDialog(f, "Could not open help page! Has it been deleted from: C:/Documents and Settings/Patrick/Desktop/",
                   "Help Menu", JOptionPane.WARNING_MESSAGE);
              // If the file cannot be loaded do not display a frame
              setVisible(false);
    public void hyperlinkUpdate(HyperlinkEvent he) {
    HyperlinkEvent.EventType type = he.getEventType( );
         if (type == HyperlinkEvent.EventType.ACTIVATED) {
    try {
    // set the page to show the selected section of the file
    jep.setPage(he.getURL( ));
    catch (FileNotFoundException e) {
    catch (Exception e) {
    }     

  • Any Way to display HTML pages on Applet

    Hi All,
    Is there any way to show web pages on Applet?
    Is it possible ?

    I am not aware of a simple way to display HTML in an applet. However, I have used the JEditorPane to display HTML documents. Handling links, etc. with this component requires some effort. Also requires Swing.
    Have you considered using the applet to display a page on the browser. (i.e. getAppletContext().showDocument(URL, [frame name]))? Just an idea.
    Good luck.

  • Displaying HTML Page

    I am having problems getting my HTML file to actually display. I think I can retrieve the file properly - I'm not getting any errors saying I can't. But when I do retrieve it, I just get a white scrollpane, instead of a scrollpane containing the webpage it should be. The following code is for an object constructor that creates the window that shows the webpage. Any help would be greatly appreciated. Thanks.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.net.URL;
    import java.io.IOException;
    public class OnlineHelpWindow extends JFrame
         public OnlineHelpWindow()
              super("Online Help");
              Container c = getContentPane();
              JEditorPane editorPane = new JEditorPane();
              editorPane.setEditable(false);
              String s = null;
              try
                   String prefix = "file:" + System.getProperty("user.dir") + System.getProperty("file.separator");
                   URL url = new URL( prefix + "index.html" );
                   System.out.println(url);
              catch (Exception e )
                   JOptionPane.showMessageDialog(null, "Unable to load URL: " + s,
                                                                "Unable to load URL",JOptionPane.WARNING_MESSAGE);
              JScrollPane editorScrollPane = new JScrollPane(editorPane);
              editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              editorScrollPane.setPreferredSize(new Dimension(250, 145));
              editorScrollPane.setMinimumSize(new Dimension(10, 10));
              c.add(editorScrollPane);
              pack();
              show();
    }

    I think you forgot to put the html page in the editor
    try putting the url in the constructor, so the url must be define first.
    JEditorPane editorPane = new JEditorPane(url);
    It should work
    Joey

  • Displaying HTML page within Flash

    Hello!
    We need to display an HTML page within a Flash executable file. We request the members of this forum to kindly guide us on how to go about it.
    Looking forward to your reply.
    Thanks and Regards,
    Hayagriva Software

    flash textfield's have limited html tags they can parse so your best bet is opening an html page in another window using getURL() (as2) or navigateToURL() (as3).

  • How to send browser display HTML page as HTML Email using JSF

    Hi all
    i need to send a whole jsf rendered page as a html page.... . say theres a page which hav few links , images etc & theres a send email button at the end of the page. once the user clicks on the button the whole page shld appear in another window which hav from,to, subject line + the html body of tht earlier page & once he clicks the send button it should send to the sender & the receiver should see the email a s a html email.where u can click on the links,images showin etc...
    Thanks
    Saman

    Subhash,
    Here is one approach..
    1. Make the report page as PUBLIC ( no Authentication required)
    2. Create procedure which will pull the page content and send it to pre-defined e-mail address
    2.1 Use utl_http.request to pull the page content
    2.2 Store the page content in some PL/SQL variable and pass it as 'p_body_html' parameter to APEX_MAIL.SEND procedure.
    3. Schedule the above procedure to run on daily using DBMS_JOB API.
    I have not implemented it and its just a thought.
    Regards,
    Hari

  • Displaying HTML page in an application

    Hello all,
    I want to display an html page in my application. I looked into HotJova HTML Component but Sun doesnt offer this component anymore. Does anyone have any idea of how can I complete this task.
    Any help will be appreciated.
    Thank you

    JTextPane

  • Help -- How to display Html text in a JEditorPane

    I'm trying to display html in a JEditorPane (html is obtained by transforming Xml and Xsl). So after i do the transformation i have a string which is the html source to be displayed. But when i use editorpane.setText(htmlString) method it is displaying the html source in the editorpane. I also tried using the HTMLEditorKit's read method. Even then its displaying the html source. But when i store the html source as a html file and give the editorpane, the url of the html file, it displays properly.
         I would be so grateful if u can help in displaying the html (which i have as a string) instead of the source...
    Thank you so much...

    Hi, after struggling with problem, the solution seems to be to ditch the content type meta tag, JEditorPane seems to barf (silently!) on this...
    So, to turn this off...
    transformer.setOutputProperty(OutputKeys.ENCODING,"");
    Cheers
    Greg

Maybe you are looking for

  • Cannot delete file on NAS Drive

    Hello, I was creating a backup of the program VLC on my NAS drive. When copying the file to the drive, it gave an error (which I now cannot recall completely... something about cannot copy certain files). When I went to try and delete the corrupted f

  • I deleted Safari from my Dock, how can i get it back please ?

    Hi all i accidentally deleted my Safari Icon from my Dock, i managed to create a Safari shortcut in Finder and dragged that into the Dock, but the Shortcut has an Arrow on the bottom left corner that looks a bit out of place !!!. How can i get the or

  • Question about the "iPod radio remote"

    I assume the "radio remote" is the same for every country and is under software control. I want to buy in Canada but use in UK and Canada. Has anyone got one and seen the RDS work, in the UK almost every FM channel is RDS. Do they have RDS in Canada

  • XML Content Upload Error - Failed to Find Handler

    Hi I am trying to upload an xml file using the tools under system administration but when I start the import I get the error cannot find handler. There are no other error messages and the view report features do not work. The handlers xml file proper

  • Service Condition Price in PR!!!!

    Hi All, If I create a purchase requisition with item category D (services) and I use a service master with a valid price in service condition maintained via ML5L, is the price then automatically retrieved in the PR line by standard SAP?? If this is n