• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to make a simple hyperlink in a swing frame

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to make a simple hyperlike like i make this class now whats i have to do for the event

import javax.swing.*;
import java.awt.*;
public class Lab extends JFrame
{
Lab() {
JPanel a = new JPanel();
Container con = getContentPane();
con.setLayout(new FlowLayout());

JLabel label = new JLabel("<html><table><tr><td>hi</td><td>helloo</td> </tr><tr><td>hi</td></tr></table>The <em><a href=e:/j.html >list</a></em> word is <b>bold</b>");
con.add(label);

setVisible(true);
setSize(200,200);
}
public static void main(String arsg[])
{
new Lab();
}
}
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
What do you want to do?
EITHER you want to trigger an event that is dispatched through a MouseClick:
Attach a MouseListener to the JLabel and do whatever you want in its implementation. Though you should think about using JButton as the user will most likely click rather on a Button than on a Label.
OR you want to display an HTML page:
For displaying HTML you need the JEditorPane. See the Swing Tutorial about it. It's very well documented. There are special event listeners for HTML links.
For triggering the display of a HTML page: The user might click on a button, and then a JEditorPane is opened that loads the URL that is specified in (or generated by) the implementation.
cheers
Chantal
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic