How to make clickable hyperlinks in Swing?

Hey all,
I know that swing supports html tags, but is this only graphics?
I'm asking coz i want to make a JLabel to have a hyperlink and when you click it, it should open ur browser and go the page.
JLabel label = new JLabel("<html><a href=\"http://www.blah.gr/\">blah...blah...</a></html>");now it has a hyperlink look but when you click it, nothing happens.
must i make the JLabel to implement a ActionListener?
and code my way to open hyperlinks?
any help will be appreciated
thanks,
avdzm
Message was edited by:
avdzm

Implement a MouseListener and override in
mouseClicked method.If you want the mouse pointer to
be changed then override mouseEntered and mouseExited
methods.What code would you put in the overridden mouseClicked method?

Similar Messages

  • I can't figure out how to make a hyperlink

    Can anyone tell me how to create a hyperlink (such as in an e-mail)? I know how to do it on a Microsoft but don't know how to on a Mac. Am I just missing the blatantly obvious???

    Thanks a lot. I am just used to using Microsoft, and couldn't understand why it wouldn't indicate that it was linked (Like how it turns blue underlined in Windows). It makes sense to me now because my friends weren't saying anything about the links not working. Once again, thanks a billion.
    -Stratocaster 13
    iBook G4 (2003)   Mac OS X (10.3.9)  
    iBook G4 (2003)   Mac OS X (10.3.9)  
    iBook G4 (2003)   Mac OS X (10.3.9)  

  • Hi puce ,how to make an editor having swing components

    hi puce please tell me how to make an editor having drag and drop facility and when after dragging and dropping components on a page save the page. The page saved should be stored in xml format and i want this application to be stand alone .. please help... ihave seen ur customizerbarsample.java ..It helped but not fully ....how after resizing and move i can get current coordinates

    Hi,
    Sir , what i would like to know is like in
    Customizerbarsample.java you have taken
    JLabelCustomizer and u drag and drop the label
    similarly i would like to drag n drop other
    components aswell and i would like to know what their
    dimensions are like the x . y coordinates both
    relative and absolute . also if after resizing i
    would like to know absolute height and width ... how
    should i go about it ... An example code would be a
    great help.... Sorry, I currently don't have the time to provide you such an example. But where exactly do you have problems? I expect you're using the example from:
    http://forum.java.sun.com/thread.jspa?threadID=737908
    as a base.
    That example shows that you can just create any TableModel you need and then create any Customizer you need from that in the consumeSelection-method.
    How to get the information of the customizers (x, y,...) I just explained in the last response. Where do you have problems there?
    i have read that if u need X, y
    coordinates along with height and width i need to
    register propertychangelistener along with
    CustomizerListener...but how do u register both
    these listeners and where.. E.g. at the place where you create the customizers:
    myCustomizer.addPropertyChangeListener(...);
    myCustomizer.addCustomizerListener(...);But what do you want to do with that? Maybe there's a better solution...
    like u instantiated
    JLabelCustomizer i tried to do the same with
    JButtonCustomizer but there was an error saying
    JbuttonCustomizer is abstract it cannot be
    instantiated..... please helpYeah, I just had a look at JButtonCustomizer and it seems as it isn't ready to use yet (probably I added some abstract methods to a base class and then just declared it abstract to be able to compile it ;) ). You can still add buttons using JCustomizer - you just won't have the in-place editing feature. Or you might want to create your own customizer derived from AbstractTextCustomizer (check the JLabelCustomizer if you need an example).
    -Puce

  • How to make clickable links in headers

    I am using POPFile to filter my mail. It is terrific. I have used it for years. It will produce a link in the header to any message. In most email programs, the link will appear clickable. But in Mac Mail, it does not. I have to highlight it, and then drag it onto my Firefox icon in the doc. That works, but I would like to find a way to make the links clickable. In Thunderbird there is a plugin called mheny, but I cannot find such a plugin for Mac Mail. Any ideas?

    Anyone...anyone? Ferris Buehler?

  • How to make Clickable Phone Numbers in PDFs

    Hello,
    I am creating Word Documents and converting them to PDFs. We put contact information in them such as names, phone numbers, email address.
    I have already got email address to work, with the hyperlinks and that converts fine to PDFs, but I am having problem with phone numbers.
    I have gone to hte hyperline and in the address typed tel:+0000000000 (of course switching out numbers), but it always attaches to a document path.  When I try to click on it in a PDF, nothing happens, but it shows clickable.  Mainly want this for people with smart phones to dial the number.
    The whole concept works in Word on a smart phone, but we lose design and pages.  That is why converting to PDFs.
    Any thoughts or help would be greatly appreciated.
    Thank you,

    The only similar thing I've encountered are hyperlinks on top of a phone number that launch Skype and attempt to call that number. In fact, I've even developed a script that automatically converts plain phone-numbers in a PDF to such links, but you have to have Acrobat to run it...

  • How to make save and restore swing components?

    hi,
    i have a problem with serialization when i trying to save a class that extends JInternalFrame class.
    err i am getting is "java.bean.PropertyDescriptior : not serialized exception". how can i get rid of this problem.
    can anyone help me in this stage so that i can complete my project.
    thankx in advance.

    Make this class implement Serializable

  • How to make a hyperlink to open new small window?

    HI!
    I try to make Dreamweawer to do next action when i click on
    some hyperlink on my page:
    - open new small sized window that does not have any
    navigation buttons from browser (back, forward, stop,...)
    - in that window there should be only picture and some text
    Probably stupid question ...but i would be happy if someone
    can help me.
    Thanks all
    Xedor!

    Go to Dreamweaver Exchange and search for "Smart Link." The
    extension is free, and it will meet your needs mentioned above.
    Good luck!

  • How to make all hyperlinks in my document inactive, like you could in the old pages under link inspector

    In the pages 09 one could click inspector and the link inspector had a box, make all links inactive.  Where is this in the new pages?  It is needed for School papers. and editing. 
    Thx

    Hi Hans,
    Doesn´t anyone no a way to, at least, avoid getting automatic-underlined-coloured links?
    Try this:
    Untick Smart Links.
    Regards,
    Ian.

  • How to make a hyperlink to a document ?

    Hello !
    I would like to drag the document from the Finder and drop it in the URL text field of the Hyperlink Inspector - as simple as this.
    In Address Book there is something similar closer to want I want : the Get Info of an Event has a url text field which can be set by dragging the document I want to reach. However I need to cut off the name of the document and leave the whole path, so I can reach the folder in which the document resides - which is not too bad.
    To sum up, from the text of a Pages document which cites another document anywhere on my disk, I need to refer to it and reach it from Pages - obvious isn't it ?
    Merci beaucoup.
    Francis

    J'ai l'habitude de répondre en Français quand le questionneur es francophone.
    Je ne me suis jamais fait taper sur les doigts par un modérateur pour cela.
    J'ai posté l'extrait de table des matières pour vous indiquer qu'il est possible de créer un lien entre deux documents Pages mais pas entre un document Pages et un PDF.
    Il y a peut être une possibilité.
    En gros : activer le Partage Web (noter l'adresse) et placer le document PDF dans le dossier Bibliothèque:Webserver:Documents.
    Depuis l'application, créer le lien vers la page web > http://<l'adresse précédemment notée>
    Attention, je n'ai pas testé cette bidouille.
    Yvan KOENIG (VALLAURIS, France) vendredi 25 mars 2011 21:01:08

  • How to make a Multiple-rows Swing menubar?

    Hello!
    I'd like to le JMenubar to show multi-rows automatically in JFrame or JApplet if one row can not show all menus.
    Does anyone know how to do it? (I've asked several times these days but seems no one knows answer)
    Thank you very much.

    If your design requires that many menubar items that it can't be displayed on a normal window, then perhaps you should reconsider your design. If you really think it is your only option than you can try changing the layout of the menubar.JMenuBar mb = new JMenuBar();
    mb.setLayout(new GridLayout(5, 2));

  • How to make the swing drawings to appear in a specific jPanel?

    hi,
    I have a frame which I divided in two panels - one for the jComboBoxes/buttons and the other one for showing graphics. but the paint(Graphics g) overpaints it all =(
    how should my code look like if I want some rectangles (depending on the combo choices and on button click which means update) to appear in the second panel?
    the code's structure is like :
    import *;
    public class NewJFrame extends javax.swing.JFrame {
         private JPanel jPanel1;
    public static void main(String[] args) {
              NewJFrame inst = new NewJFrame();
              inst.setVisible(true);
         public NewJFrame() {
              super();
              initGUI();          
         public void paint(Graphics g) {
              g.fillRect (x, y, w, z)
         private void initGUI() {
              jPanel1 = new JPanel();
                   // combo boxes and buttons
                   // action listeners for them
              jPanel2 = new JPanel();
                   // the place where the rectangles should be shown
                   // and updated if combos are changed and button clicked
    }now, I wonder if anyone could possibly give me a hint how to make it correctly, because I'm really a total newb in Java and I can't find any good examples from www which I've search through for the solution.
    P.S. is there a plug-in for eclipse for visual programming of the graphics? =)
    thank You for the kindest help!
    J.M.

    You should not be mixing AWT and Swing component in
    a Swing application, so don't use a Canvas.
    If you need some custom painting then you should
    override the paintComponent() method of JComponent or
    JPanel and then add this component to the GUIwhat does mean the override the paintComponent() method of JComponent or JPanel?
    how can I add that component to the GUI?
    =)
    can you give a short code example, please! the code structure would be more than enough.
    J.

  • How to create a clickable hyperlink in iCloud Numbers?

    How to create a clickable hyperlink in iCloud Numbers?

    There is no such thing. All you could do is create an HTML e-mail, but many users won't even view it in that mode for security reasons and it may get filtered. Similarly, Flash-based content may get removed/ not show up. So at best, if you really want to get a clickable document, you could use a PDF file containing a link. but did i mention that the user can suppress those, too? Well, sorry, but you are SOL. You want something that for a million reasons nobodyy can give you. The best you can do, as always, is host your content on a proper website and send peopel a link to it...
    Mylenium

  • How to make hyperlinks in JTextField/JtextArea  ??

    My JTextField/JtextArea has got this Text.
    String text = "Get information from http://www.hotmail.com, if you have problems go to http://www.google.com " ;
    How to make hyperlinks for http://www.hotmail.com and http://www.google.com texts only???
    And how to call those sites???

    Add a mouse listener, when the user double clicks - see if they've clicked on text that is a valid link.
    The limitation of using textfield or textarea is that you get no styling. I dont know why you're refusing those suggestions, but you're just creating more work for yourself.

  • How can i make my hyperlinks open in a new window or tab?

    how can i make my hyperlinks open in a new window or tab?

    The program is InDesign… we need to cease links which will open the linked document in a separate window.  Also, the links must be maintained once a pdf is made and the files moved to another computer….

  • How to make the diagonal line in the swing table cell?

    Hi all,
    How to make the diagonal line in the swing table cell just like the link below?
    http://61.132.17.188/webber/table.gif

    One improvement.. To get a line that is neat, use a bit of Graphics2D
        public void paintComponent(java.awt.Graphics g)
            int w = getSize().width;
            int h = getSize().height;
            // draw a line between (0,0) and (w,h)  
            g.setColor(getForeground());
            if (strTop == null)
                strTop = "  ";
            if (strBottom == null)
                strBottom = "  ";
                java.awt.Graphics2D g2 = (java.awt.Graphics2D)g;
              g2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING,java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
              //g2.setStroke(new java.awt.BasicStroke(14.0f));
            g.drawLine(0, 0, w, h);
            //the following lines will draw the two strings,
            //one above the top of the line and the above below it.     
            g2.drawString(strTop, (w/2)+2, (h/2)-2);
            g2.drawString(strBottom, 2, (h / 2) + 2);
            //the x,y for drawString are only based on assumption.   //do necessary changes to suit ur needs.
        }Then create a TableCellRenderer and set it to the Table Header for ur table's 1st row.....
    Cheers

Maybe you are looking for