Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clickable Text

Status
Not open for further replies.

youngun

Programmer
Apr 27, 2001
61
US
I have a ticker program, and I want the text in the display window(frame) to be clickable, and redirect to a web page with browser pop out.

Thank you very much.
 
You can add a MouseListener to the component with the text like this:

component.addMouseListener(new MouseHandler());

then you create an inner class MouseHandler which handles the mouse events like this:

private class MouseHandler extends MouseAdapter {
public void mouseClicked(MouseEvent e){
// redirect to page
}
}

I don't know how to do the browser popup (yet... ;-)) regards,
Blaxo
 
Blaxo,

Will this work for dynamic text display? Because ticker program display real-time information. Thank you.

Youngun
 
It depends on how you display your text...

Do you use a (J)Label? Or do you draw it on a Canvas or something?

And even if you do, all these Components recognize the mouseClicked event, so it will work I think.
regards,
Blaxo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top