Java Desktop program making LinkButton (link tag) __java

Source: Internet
Author: User

Import Java.awt.Cursor; Import Java.awt.FlowLayout; Import Java.awt.event.MouseAdapter; Import java.awt.event.MouseEvent; Import java.io.IOException; Import Javax.swing.JFrame; Import Javax.swing.JLabel; /** * Hyperlink button. * * @author Elvis */public class LinkButton extends JLabel {private static final long serialversionuid = 1L; private Str ing text; Private Cursor handcursor = new Cursor (cursor.hand_cursor); Create a cursor for the finger type of mouse public LinkButton () {Addmouselistener (new Mouseadapter () {public void mouseclicked (MouseEvent e) {runt IME RT = Runtime.getruntime (); try {String cmd = "rundll32 Url.dll,fileprotocolhandler http://ice.kane.blog.163.com"; rt.exec (cmd);} catch (Ioexceptio N E1) {e1.printstacktrace ();} setclickedtext (); Set text-style event public void mouseentered (MouseEvent e) {sethandcursor (), Setmoveintext ()///mouse out label, set Text style event Publ IC void mouseexited (MouseEvent e) {setdefaultcursor (); Setmoveouttext ();}}); //Set initial style public void SetText (string text) {String content = &lT;html><font color=blue> "+ text +" </font>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.