JEditorPane HTML Link

Hey all
I've been at this for days trying to figure it out. I have found lots of examplecode and it just refuses to work for me. Starting to feel really dumb, so I'm gonna ask you guys for help.
Single class, runnable but does notregister when you click on a link.
* Created on 2005-jan-04
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
* @author Daniel Wahlgren
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.io.*;
import java.net.*;
import javax.swing.text.html.*;
public class About extends JDialog{
     private JDialog about;
     private JEditorPane text;
     private JLabel image;
     private JLayeredPane jLayeredPane;
     private JPanel bg;
     public About(){
        super();
          int width = 400;
          int height = 300;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          about = new JDialog();
          about.setTitle("About");
          about.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
          about.setUndecorated(true);
          about.setSize(new Dimension(width,height));
          about.setBounds((screenSize.width-width)/2,(screenSize.height-height)/2,width,height);
          about.setAlwaysOnTop(true);
          about.setResizable(false);
          jLayeredPane = new JLayeredPane();
        jLayeredPane.setSize(new Dimension(400, 350));
          bg = new JPanel();
          bg.setBackground(new Color(255,255,255));
          bg.setBounds(5, 5, 390, 290);
          image = new JLabel();
          image.setIcon(new ImageIcon(getClass().getResource("resources/dannyprogram.gif")));
          image.setBounds(5,5,160,160);
          image.setFocusable(false);
          text = new JEditorPane();
          text.setEditorKit(text.createEditorKitForContentType("text/html"));
          text.setContentType("text/html");
          try{
               text.setPage(new URL("http://www.google.com"));
          } catch (IOException ioe){
               System.err.println("An error ocurred: " + ioe);
          text.setBounds(165,5,230,290);
          text.setFocusable(false);
        text.addHyperlinkListener( new HyperlinkListener() {
             public void hyperlinkUpdate(HyperlinkEvent evt){
                  System.out.println("Clicked");
          JButton Close = new JButton("Close");
          Close.setMargin(new Insets(5,5,5,5));
          Close.setBounds(35, 265, 100, 25);
        Close.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                closeActionPerformed(evt);
        jLayeredPane.add(text);
        jLayeredPane.add(image);
        jLayeredPane.add(Close);
        jLayeredPane.add(bg);
          about.add(jLayeredPane);
          about.setVisible(true);
    private void closeActionPerformed(ActionEvent evt){
         about.setVisible(false);
     public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new About();
}

Read the JEditorPane documentation for an example of a HyperlinkListener that functions

Similar Messages

  • JEditorPane HTML link in the same page

    Hi,
    I want to show an HTML page in JEditorPane.
    The HTML page have <a> tags that link to a bookmark in
    the same page, but I can�t show this because I get an error
    like this:
    MalformedURL or similiar.
    I try to do somethig like this:
    public void hyperlinkUpdate(HyperlinkEvent ev)
    ...Editor.setPage(ev.getURL());
    or
    ...Editor.setPage(ev.getDescription());
    without results.
    How can I listen for hyperlinksEvents than link in the same page.
    Thanks

    they dont want to see the first report.
    Is there a way in which the Prompts are also display along with the second report?Then create the same prompt on the second report also.
    Cheers
    Nawneet

  • 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) {
        }

  • Swing Applets && HTML links

    Hi Sun Team and Swing Fans!
    I am trying to embed Hypertext Markup Language in my Swing applet..or sould I say..I am trying to add an HTML link in my Swing applet...
    The body looks something like that:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class images extends JApplet implements ActionListener {
    bla bla bla .... My program
    Is there a way to do that and if there is, how do I implement it?
    Thank you very much in advance, Albert.

    Howdy,
    If you just want a simple link on your page you could either draw you link on the page and then when mouse down get the coords to see if over your link then:
    try {newURL = new URL("http://www.counter-strike.net");}
                   catch (MalformedURLException e1){}
                   getAppletContext().showDocument(newURL);
    for example. Or you could embed a JEditorPane with HyperlinkListener, in that case you will need to import Javax.swing.event (I think).

  • 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

  • Can I use a report item as a parameter in an html link.

    I have a report (build using the Query Wizard) that selects and
    shows data from a database on a seperate system (via a database
    link). The first column of the report gives an ID Number that I
    want to use as part of an html link to display the full details
    of the item.
    So if the item on the report has a value of 123456 I want my
    html link to create a url of http://system/plsql/show_details?
    thingid=123456
    Any ideas?

    We are using dynamic pages to accomplish that goal. The links
    actually go to items/folders within portal, but it would be the
    same thing.
    I have found using the combination of links and reporting tools
    to be very limited on the site when it comes to trying to create
    links to things other than forms or other reports. That is
    probably 90% ignorance on my part, but I have not been able to
    accomplish this in any way other than a dynamic page.
    Any suggestions on building a dynamic link within a portal
    created report to a portal page/item would be appreciated.
    I have also tried to concatenate in a <a href> tag in a SQL
    Query based report, but generally errors. We have also created
    a view that creats the link for us, that could be another option
    for you, if the link is static.
    Good Luck and hope my ramblings make sense.
    Brian

  • Adding a html link to a carousel

    i have followed a tutorial to build a flash craousel and have had no problems in building that.  i wanted to add a html link to a section of the carousel but everything i have tried up to now has failed.  All the information is passed through to the carousel from an xml file and everything works fine except for the link.
    i have slightly modified the tutorial so i have an extra box on the information page which holds the web address for the site they are looking at in the portfolio.  i have the address showing up but i cannot use the text as a link.
    the box that i am putting it in is a dynamic text box which has been set up with the following settings
    theLink.html = true;
    theLink.htmlText = t.Link;
    so as far as i know these are set to be able to handle html tags/code but they are not playing games.
    i have tried to pass the link through to the swf file from the xml file with the following code but this just seem to break the whole application.
    Link="<![CDATA[<a href='http://www.acmeart.co.uk/pip_new']]"
    to view how i have the file working upto now please view the link below.
    http://acmeart.co.uk/carousel
    i feel the problem is not with the flash application but more with how i am trying to pass the html link over to the application from the xml file.  i will attach the xml file to the post.

    What I had in mind was to place the link inline in your text. Something like this:
    <item name="valley" full="assets/valley.png"
            title='Book - CD ROM'
            body='This product was a Shockwave holiday card. It began as a jigsaw puzzle. As the puzzle was solved, it opened and displayed the holiday greeting. &lt;a href=&quot;http://www.amazon.com" &gt;Purchase a copy.&lt;a\&gt;'>
        </item>
    The url is right in the text. The html markup is escaped as html entities.

Maybe you are looking for