JEditor Pane & Html links

Hello! I'm using a JEditorpane to display a HTML page but i'm experiencing the following problem:
* I'm using images as links but link fonctionality only appears in some parts of the image, not all over it.
I create the html code in a String :
String code ="<a href=""><img ...></img></a>";
and then
jEditorPane.setText(code);
Do you know what is happening??
thanks!

I used JTextPane, and it worked correctly, the only headache was Java's HTML rendering engine, which sucks.
Anyway, try a code like this:
JTextPane pa=new JTextPane();
JScrollPane scroller=new JScrollPane(pa);
TheComponentYouWantToDisplayTheRenderer.add(scroller);
pa.setEditable(false);
pa.setEditorKit(pa.createEditorKitForContentType("text/html"));
// Here you can set the page you want to display
// Unfortunately there is no progress meter,
// you need to work around it...
pa.setPage("http://java.sun.com/");If you want to follow links, you have to add a HyperlinkListener to the page, like this:
pa.addHyperlinkListener(new Hyperactive());
class Hyperactive implements HyperlinkListener {
     public void hyperlinkUpdate(HyperlinkEvent e) {
          if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
               if (e.getSource()==null) return;
               JEditorPane pane = (JEditorPane) e.getSource();
               if (e instanceof HTMLFrameHyperlinkEvent) {
                    HTMLFrameHyperlinkEvent  evt = (HTMLFrameHyperlinkEvent)e;
                    HTMLDocument doc = (HTMLDocument)pane.getDocument();
                    doc.processHTMLFrameHyperlinkEvent(evt);
               } else {
                    try {
                         pane.setPage(e.getURL());
                    } catch (Throwable t) {
                         //t.printStackTrace();
}I found this code in one of the tutorials, but it was long ago, and I don't remember which was it... :-)
After this, you shouldn't have problems. But not that the img tag doesn't need to be closed, so try
<img src="imgsrc">
instead of
<img src="imgsrc"></img>

Similar Messages

  • Jeditor pane, html links opening external browers

    HI,
    i have serched the web for about half a day, i have a JEditorPane that loads a web page works fine,
    only i would really like for the links they click on to open the clients default file browser??
    so not even sure if this is the right forum as it has more to do with starting up applications?
    Thanks any links, i am sure it has been done, using somthing like Runtime? but now sure what to put in the argument.
    Thanks
    David

    i found this thread but it say it is only windows???If you follow the link to java world it shows you how to do it for other platforms as well.
    Is there any way to do this instandard java?I believen JDK6 has the Desktop API which will handle this otherwise your stuck with the hack above or a 3rd party package.

  • Issue with JEditor Pane

    Hello,
    I am trying to set a html page(which is converted from MS Word ) to a jeditorpane.The page loads fine but the hyperlinks doesn't work,they dont redirect to the appropriate topic.Its just a single page.It works fine as an individual html page but not with JEditorPane.
    Any clues,
    thanks
    Sree.

    sreecs wrote:
    The links are just table of contents in a MS Word.
    Coming from MS Word, I wonder if it's some flavor of non-standard HTML.then they shouldn't work in a standard html page too..why only when in a jeditor pane??
    thanks,
    Sree
    Edited by: sreecs on Nov 11, 2008 3:52 PMActually, MS Word-generated HTML often works fine in browsers, especially Internet Explorer. But everybody knows that it generates garbage for HTML (at least it used to, don't know about Office 2007). Browsers often go to great lengths to "get the gist" of non-compliant HTML and still render it properly (again, especially IE, which has been a criticism of web standards folks forever).
    JEditorPane has very simplistic HTML rendering support, and probably doesn't take much stuff that is non-standard. While it wasn't your problem, I am sure you could use pretty easily use Word to generate HTML that JEditorPane couldn't render properly.

  • HTML link in a Java?

    Hya,
    How can create a HTML link in Java GUI, for example in a JLabel?
    thanks inadvance

    I'm not quite sure but i think if you add addHyperlinkListener to the jlable it will be seen as a link.
    Have a look at this code example:
    try {
            String url = "http://www.google.com";
            JEditorPane editorPane = new JEditorPane(url);
            editorPane.setEditable(false);
            editorPane.addHyperlinkListener(new MyHyperlinkListener());
        } catch (IOException e) {
        class MyHyperlinkListener implements HyperlinkListener {
            public void hyperlinkUpdate(HyperlinkEvent evt) {
                if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    JEditorPane pane = (JEditorPane)evt.getSource();
                    try {
                        // Show the new page in the editor pane.
                        pane.setPage(evt.getURL());
                    } catch (IOException e) {
        }

  • JEditor pane does not look like the explorer.

    Hi
    I would like to display the following htmlc ode on JEditor pane.
    I want to have two lists of assets and a title to each one.
    the problem is that one of the titles (the second one) does not displayed in the same location as the first one (It displayes ans if it is part of the list)
    I copies the code to a htm page and it looks fine on my explorer.
    I will be happy if you will tell me what is wrong in the html code.
    thanks
    Liat
    JEditorPane summeryMessagePane;
    summeryMessagePane=new JEditorPane("text/html","");
    //html string
    String text="<html><body><font face = Verdana size =2 color=black>The following files were defined successfully:<li><font face = Verdana size =2 color=black>/LDRS/mummy2_opt8_pal_2500kbps_10m_l2_ar128kbps.m1s.mpg</font></li><li><font face = Verdana size =2 color=black>/LDRS/nely_opt2_10m_pal_1860kbps_l2_128kps.m1s.mpg</font></li><br>The definition for the following files failed:<li><font face = Verdana size =2 color=black>/LDRS/mummy2_opt8_pal_2500kbps_10m_l2_ar128kbps.m1s.mpg.meta</font></li><font face = Verdana size =2 color=black>Unsupported asset format.<li><font face = Verdana size =2 color=black>/LDRS/nely_opt2_10m_pal_1860kbps_l2_128kps.m1s.mpg.meta</font></li><font face = Verdana size =2 color=black>Unsupported asset format.</font></body></html>"
    //set the string
    summeryMessagePane.setText(text.toString());
    JScrollPane scrollPane = new JScrollPane(summeryMessagePane);
            add(scrollPane,BorderLayout.CENTER);

    What ever gave you the idea that HTML display on JEditorPane would look exactly like in IE?
    JEditorPane only supports HTML 3.2 (but no frames, I think), some CSS 1 and no Javascript. It's very far from being useful for displaying modern web pages.
    Furthermore....
    <font face = Verdana size =2 color=black>
    Bad bad bad bad bad HTML format. You are supposed to always quote tag attribute values:
    <font face="Verdana" size="2" color="black">

  • ANYONE CAN HELP IN JEDITOR PANE!!Help

    I am displaying the HTML form inthe Jeditor Pane..It is working,but the only problem now is when i embed flash inside HTML ,it output shown symbol ??\How to overcome this

    Thanks DR>CLAP for ur solution,Do u have any alternative plan for this

  • HTML links in Vibe Feed and digest e-mails do not work on GW 8.0.3client

    I have GroupWise 8.0.3hp1 on NetWare 6.5.8 and a Vibe 3.3 install on
    SUSE 11 (the downloadable Vibe demo virtual machine from Novell's site).
    I have recently started upgrading GroupWise clients on Windows 7 PCs
    (64bit), and have been testing Vibe. I have run into a problem with
    HTML links in GW clients not working on PCs where the GW client has been
    upgraded.
    This problem occurs using the GroupWise 8.0.3hp2 and 8.0.3hp3 clients,
    but does not occur on a 8.0.2hp2 client, so it appears to be GroupWise
    client related. I haven't tested any other client versions.
    1. When using the GW 8.0.3 client, if I select any of the "Novell Vibe
    OnPrem", "Favorites", or "My Teams" folders, I can see the Vibe Feed
    display showing entries for sites I'm following. But clicking on the
    links in these entries does nothing, so I cannot use the Vibe Feed to go
    directly to files, profiles, etc. The same Vibe Feed links from the
    Vibe web browser interface or from a GW8.0.2hp2 client works fine.
    2. If I have e-mail digest notifications setup to let me know when
    changes are made to a folder or file in Vibe, the e-mails are delivered
    to me just fine. But once again, none of the links in the e-mails work
    when using the GW8.0.3 client. Clicking on them does nothing. If I
    look at the e-mail message source, I can copy-and-paste the URLs
    directly into a browser and they work fine, so the URLs themselves are
    correct. Again, these links work fine if I use the GroupWise WebAccess
    or a GW8.0.2hp2 client.
    Is the GW 8.0.3 client is blocking these HTML links? I receive no
    notification from the client asking whether to "unblock" any
    links/scripts/images when viewing messages with these Vibe links.
    Any suggestions for getting these to work on GW 8.0.3 client?
    Thanks,
    -Greg
    former e-mail for posting:
    [email protected]

    Greg,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://forums.novell.com/

  • Preserving HTML links when converting Word docs

    I created a document in MS Word for Mac 2011 (ver 14.5.2)
    When I used Adobe Pro 11 to convert the document into pdf format, all the HTML links are lost. 
    I have tried converting from MS Word, opening the word version with Adobe Pro, printing from MS Word to pdf.  Nothing works. Even opened the MS Word document using Apple's Pages software, re-formatted and then converted to pdf.  Still no live links.
    Best work around so far is to convert and then use the edit feature in Adobe Pro to re-insert the HTML links as invisible rectangles on top of the still-blue-and- underlined text.  So to the user it looks like the html links are still live, but what a pain for editor.
    I have seen this issue raised in other posts, but none of the answers seem to work. And the work around described above is clearly less than ideal.
    Very curious, as reading other posts, the issue apparently does not arise when the word doc converted from a Wintel computer.  But I can't imagine Adobe writes software one way for Intel and another for Mac.

    Imagine it. this has been 15 year fued between Microsoft and Adobe.  Adobe Claims that Mac office doesn't hav ethe proper hooks for URLs. Microsoft says the fault is with adobe.
    Since a Word Created file will work when opened in the windows version  and saved as a PDF, the links work just fine. Just opening and not saving, but converted to Pdf does nothing to the actual Word File.
    They had it fixed last year  in Acrobat X if your dropped the file on to Acroabt directly. But broke it again with the upgrade to XI.
    IF you have iWork and Open the word file in Pages then exported as a Word.docx file then create The PDF the links will become active.  Also if you Open in OpenOffice and export as docx file the resulting PDF when open in Word and PDF is Created the links will become active.
    If you have neither you will have to open the PDF and add the links. Note the Links will be hot (active) but the links will not turn Blue and  be Underlined
    Mac Office2011 is a Conversion of Office2010/2007 code.  So there should be no pproblem.
    Also Don't use the Save As . . .  PDF Method. Instead go to Print Menu  click on PDF wait for context menu > the choos Adobe Quality PDF or Adobe PDF (uses Adobe's PDF engine).
    wait for next screen that shows qualtity leave as sent unles you need specific job options. click okay then next screen File name. Rename as necessary the browser to desired to location then click save.  Or you can drop the saved Word document (with Word quit.) on to Acrobat and after a minute or so the PDF will be created. (Using this method in AcrobatX would actully show URL s or Mailtos as active - They broke this in Acrobat XI PDF still can be created but hot links no longer work).
    Well it seems it does work on occasion  see: http://www.screencast.com/t/cib2kcYG

  • HTML Link to Product Revenue Detail Page

    I have a simple table report developed for the Product Revenue.
    Help me with either "Custom Text" using ActionLink or a HTML Link for navigating to Product Revenue Page.
    I tried following link
    http://"@[html]"<a target=_blank href=https://secure-ausomxafa.crmondemand.com/OnDemand/user/RevenueDetail?OMTHD=RevenueDetailNav&OMTGT=RevenueDetailForm&RevenueDetailForm.Id="@">"Click"
    Thanks
    Edited by: user648222 on Jan 22, 2009 7:54 PM

    Try this:
    'Product Detail'
    the product revenue needs the Opty ID to be passed into it. If this doesn't paste properly email me at alex.neill@{see profile} and I'll email it to you.
    cheers
    Alex

  • How Do I Make HTML Links Open in Same Window?

    Hi
    How on earth do I get the HTML links inside a flash movie open up in the same browser window where said movie is embedded in (As opposed to opening up as a new pop-up windows)? Here is the code I have inside each of the buttons I have inside my flash movie:
    var link7:URLRequest=new URLRequest("videos/december.html");
    videos_btn.addEventListener(MouseEvent.CLICK, buttonClicked7);
    function buttonClicked7(event:MouseEvent):void
    navigateToURL(link7);

    Thank you thank you thank you!!!

  • How do I add an html link/banner to a page in my flash website?

    I purchased a flash website template and am in the process of editing my main.fla file.  In order to get listed on an advertising website with a higher rating, I have to place a reciprocal link to them on my site.  However, I cannot figure out how to place an html link/banner on my site for other businesses.  If I paste the html code in a text box, all that shows up is the html code rather than the image and link it is meant to generate.  Please help!

    Flash only supports a small amount of html in text areas.  If what you re trying to include is within what it supports, then you assign the text to the textfield using the htmlText property of the TextField...
    tfield.htmlText = "<a href="...">link</a>"; // will display "link" as a link

  • Is there a way to select MULTIPLE tabs and then copy ALL of the the URLs and titles/or URLs+titles+HTML links? This can be done with the Multiple Tab Handler add on; However, I prefer to use a Firefox feature rather than download an add on. Thanks.

    Currently, I can copy ONE tab's url and nothing else (not its name). Or I can bookmark all tabs that are open. However, I'd like to have the ability to select multiple tabs and then copy ALL of the the URLs AND their titles/or copy ALL of the URLs+titles+HTML links? This can be done with the Multiple Tab Handler add on; when I download the add on, I get a message saying that using the add on will disable Firefox's tab features. I prefer to use Firefox features rather than download and use an add on. Is there a way to do this without an add on?

    Hi LRagsdale517,
    You should definitely be able to upload multiple files by Shift-clicking or Ctrl-clicking the files you want to upload. Just to make sure you don't have an old version of the service cached, please clear the browser cache and then log in to https://cloud.acrobat.com/files. After clicking the File Upload icon in the upper-right corner, you should be able so select multiple files for upload.
    Please let us know how it goes.
    Best,
    Sara

  • How can i send data POST with a html link in a textfield

    Hello,
    This is my problem : I generate (from a php script) html
    links in a textfield. I would like for each link to send data with
    the POST method to an other script.
    My problem is that the getURL("lien", "", "POST") function
    can be use only by a movieclip or button event ... and not from a
    html link ...
    How can i do it ?
    Have you a small idea???
    Thanks ....

    yes, thanks but now my problem is in my function associated
    to this link :
    function SendPost()
    var toto="toto";
    getURL("
    http://127.0.0.1/board/scheduledfirst.php",
    "_blank", "GET");
    The function is executed but after in php i can get anything
    with echo ($_GET["toto"]); echo ($_POST["toto"]);
    Why ?

  • Is there a way to include html link with applet?

    I am thinking of writing an applet that would be useful to others, which I would provide for free. In return I would want a link from the pages that use the applet. It is important that the link is search engine friendly, a pure href html link that will provide google page rank to me.
    Is there a way to include such a link with an applet so that it can't be removed?

    No. You can't force other sites to change their content.

  • Flash hijacking HTML links while images are loading

    I've designed a slide show player using Flash and Actionscript 3.0 which loads several external images. While the images are loading, the HTML links on my page (outside of the Flash movie) don't work. As soon as all the images are loaded, the links start working again. It seems like the Flash player is hijacking the browser while the images are loading which can take the better part of a minute depending on my connection speed. I can click an HTML link once during the loading time and as soon as the images have loaded, the browser loads the new page (the one the HTML links to). Once all the images are in my Temporary Internet Files folder, this problem ceases to exist (since the images no longer need to be downloaded). It's only first-time viewers that will have this problem, but it's a pretty major problem.
    To see what I'm talking about, go to:
    http://www.ericlindberg.com/indexTemp.html
    Click the Images button after the "Loading..." animation disappears but before all the images are loaded. As the images load the thumbnails at the bottom of the Flash player go from 50% to 100% opaque. If  you click the "Images" button before all the thumbnails are 100% opaque, nothing happens. However, once they are all loaded and the thumbnails are all 100% opaque, the "Images" page loads. You can do the same thing with any of the subpages in the Images section of the site and get the same results.
    Any advice would be greatly appreciated.
    Joe    

    I have something similar on my site.
    http://alt-web.com/gallery.shtml
    You might try using CSS rollovers instead of MM (javascript) rollovers.  Straight HTML links load fast and work immediately.
    http://alt-web.com/DEMOS/CSS-Sprites-II.shtml
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb

Maybe you are looking for

  • Reader v11 Update fails on Windows Vista (entire network) with error 1310

    Tried to run the Reader v11 updater after installing v11.  It fails comsistently with error 1310, although the file in the error message is different each time.  The file is usually, but not always, in the folder config.msi. We had this problem in th

  • ATV 3.x Update & Issues

    I've read enough comments now to know that the problems I'm experiencing are not at all unique. The 3.x ATV software update absolutely *****. What I want to know is why the heck Apple's engineers felt the need to make such radical changes, and why th

  • Using BETWEEN in Query in BI Publisher

    I wanna use BETWEEN , to be used between 2 parameters as the following : AND TO_CHAR(T8.ATTRIB_13,'DD/MM/YYYY') BETWEEN NVL(:P_DAT,TO_CHAR(T8.ATTRIB_13,'DD/MM/YYYY')) AND NVL(:P_TO,TO_CHAR(T8.ATTRIB_13,'DD/MM/YYYY')) this statement does not give me a

  • How to save an image in sql server

    hi i want to save an image in the database what are the possible solution.Please suggest thanks

  • Execute procedure based on condition...

    Hi, I have two procedures proc1 and proc2. create or replace procedure proc1(dpt_id number) begin select dept_name into dname from department_sect where dept_id=dpt_id; dbms_output.put_line(dname); end; create or replace procedure proc2(dpt_id number