hyperlink in application?

How can I insert a hyperlink into an application so that when the user clicks on it, the user's default browser is opened to the specified link?
[159 byte] By [bheimsoth] at [2007-9-26 4:11:32]
# 1

to insert a hyperlink into an application you need something like this

//create the html pane

pane = new JEditorPane();

pane.setEditable(false);

//display the page within it

pane.setText(htmlContent);

//add a hyperlink listener to the pane

pane.addHyperlinkListener(new HyperlinkListener() {

public void hyperLinkUpdate(HyperlinkEvent e) {

//code that launches the default browser using link

}

}

however, thats the easy bit. im not sure how to do the system default browser. for a specific way you could do something like

Runtime.getRuntime().exec("iexplore " + e.getDescription())

hope it helps

Chris

cpc9 at 2007-6-29 13:16:31 > top of Java-index,Archived Forums,Java Programming...
# 2

whoops. also in it you need pane.setEditorKit(new HTMLEditorKit())

and if you only want the listener to respond on clicks youd also need in the listener

if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)

{

//code

}

cpc9 at 2007-6-29 13:16:31 > top of Java-index,Archived Forums,Java Programming...