Results 1 to 2 of 2

Thread: JEditPane

  1. #1
    DanielS is offline Member
    Join Date
    Nov 2008
    Posts
    11
    Rep Power
    0

    Default JEditPane

    Let me try to explain this...

    I have a JEditPane. I also have a string of html code.

    PHP Code:
    <html>
    <body>
    <img src="images/mypic.jpg">
    </body>
    </html>
    * the html is shortened.

    What I want to do is use setText() to set the code of the edit pane.

    If I do this, the picture doesnt show, it shows the small broken picture icon.
    However, if I load the page via setPage() with a file, the picture shows. After I use setPage() I can then use setText() and the picture shows.

    I'm guessing that something is being initialized in the edit pane when setPage() is called. Because after setPage(), the setText() calls work fine.

    I would like to be able to do this without having to call setPage() first.

    Heres a small example...
    PHP Code:
    String html = "<html><body><img src="images/mypic.jpg"></body></html>";
    
    editPane.setText(html); // <-- Does not work... picture does not show.
    
    editPane.setPage("file:///whatever.html"); // <--- Works, Picture shows.
    
    editPane.setText("whatever"); // Set it to random text.
    
    editPane.setText(html); // <-- Works, picture shows. Because setPage() was called?

    Thanks!

    Edit: This question was also posted at coderanch. I cant post a link... not enough posts.
    Last edited by DanielS; 02-22-2009 at 09:24 PM.

  2. #2
    devunion is offline Member
    Join Date
    Jun 2008
    Posts
    56
    Rep Power
    0

    Default

    Try to use URL with absolute path for the image.
    Try Controls4J - Advanced Swing Components.

Similar Threads

  1. JEditPane
    By DanielS in forum New To Java
    Replies: 0
    Last Post: 02-22-2009, 05:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •