Displaying html page in JEditorPane

yeh, yeh, i know the editorPane.setPage(url) function. the problem is that the file i need to display (help.html) is on local drive, in the same dir as the class with the editorPane. so what url do i make [i don't know in which dir the class will be]. i tried to make it relative: URL url = new URL("help.html"), but it didn't work. this:
s = "file:\\"
+ System.getProperty("user.dir")
+ System.getProperty("file.separator")
+ "Help.html";
URL helpURL = new URL(s);
doesn't work either.
i work on win 95, jdk 1.3.
HELP ME!
LionAlx.

yeh, yeh, i know the editorPane.setPage(url) function.
the problem is that the file i need to display
(help.html) is on local drive, in the same dir as the
class with the editorPane. so what url do i make [i
don't know in which dir the class will be]. i tried to
make it relative: URL url = new URL("help.html"), but
it didn't work. this:
s = "file:\\"Try "file:\\\"

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

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

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

  • How to go to anchor html link from external html page in JEditorPane

    Hi people,
    I've been trying to jump to an anchor link from an external html page in JEditorPane, and I cannot get it working, I'm sure it can be done somehow...
    The HTML page has a link like:
    Hello
    and this is loaded into JEditorPane ok.
    The HyperlinkListener implementation:
    public void hyperlinkUpdate( HyperlinkEvent e )
    try {
    if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED )
    editorPane_.setPage( getClass().getResource(
    MyDialog.this.getBaseURL().concat( e.getURL().getFile().substring(
    e.getURL().getFile().lastIndexOf( "/" ) + 1 ) ) ) );
    if ( e.getURL().getRef() != null )
    editorPane_.scrollToReference( e.getURL().getRef() );
    else return;
    } catch ( IOException ioe ) { ioe.printStackTrace(); }
    This code loads the new html file ok, but it does not scroll to the anchor. The MyDialog.this.getBaseURL() just returns something like com.name.package, I construct the URL by using this base url and the name of the html file to open.
    ANy help, thanks

    he! I'm not alone in my desperation. Take a look at my problem:
    I've got a JEditorPane (not editable) inside a JFrame. The JEditorPane is loaded with the HTML text and all the links to anchors are working properly when I click on them.
    BUT
    If I try to go to an anchor from outside this JFrame I can see how the JEditorPane scrolls to the right anchor and suddenly it scrolls back to the place where the caret was located!!!
    The "funny thing" is that my code is working in jdk1.3.1 but this is happening in jdk1.4.2. Is it a bug?!?!?!
    How could I figure out what position I have to set the caret to for every anchor in order to get the scroll working correctly???
    My implementation of hyperlinkUpdate (working properly, here isn't the problem):
       jEditorPane.addHyperlinkListener(new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              MiEditorPane src = (MiEditorPane)e.getSource();
              src.goToAnchor(e.getDescription().substring(1));
        });My object jEditorPane is an instance of this class:
      class MiEditorPane extends JEditorPane {
        MiEditorPane() {
          super();
        public void goToAnchor(String anchor) {
          super.scrollToReference(anchor);
      }And this is the method I call from outside the JFrame containing the JEditorPane:
      public void goToAnchor(String anchor) {
         jEditorPane.goToAnchor(anchor);
      }Any help greatly appreciated ...

  • 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

  • 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

  • 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

  • Problem Printing html page with JEditorPane...

    Hello All,
    I Have a problem in printin html file with JEditorPane...
    My Html file contains a Table on it..
    Problem is that JEditorPane displays the html file correctly but
    it prints the file without print that Table..
    So pls help me...
    Thanx in advance,..
    Amit
    [email protected]

    I think you would know how to retrieve content of an HTML page using the URL object. Just in case.
    My apology if this short note doesn't help you at all.

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

Maybe you are looking for

  • Help! How to read data from an Excel file?

    Hi, I need to read data from an Excel file that may contain more then one table in a sheet. How can I read them? I would be eternally grateful to anyone who can give me any information.

  • Itunes will no longer import

    My itunes has suddenly decided not to let me import anymore. I have tried multiple CD's. It will start importing, get through one or two songs and freeze up the whole computer so I have to cold start it. It does this when i load songs to my folders t

  • Miix 2 8 - Blue Screen of Death when accessing webcam(s)

    Hi Lenovo! I have a Miix 2 8". When I open one of the camera apps, the device can lock up and bluescreen, with the BAD_POOL_HEADER error. This happens once in a while. I have the automatic mini memory dump (C:\Windows\minidump) when it happened, I ca

  • Double buffering images

    HELP!!! lol i'm trying to figure out how to get the whole double buffering thing to work with a picture like a gif image i drew in paint. i can't quite understand anything aobut how to do it. lol i've read some things and looked at some code samples

  • Problem with Keymaps

    Hi, I got a problem with a user-defined keymap. Here is a fragment of my code: for (int i = 0; i <= 1; i++) { keymap[i] = textField.addKeymap("Bindings" + i, textField.getKeymap()); prepare_keymap(i); textField.setKeymap(keymap[actKeymap]); private s