Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.Cursor;

import javax.swing.JLabel;

public class Main {
    /**
     * Configures a label as if it was an hyperlink.
     * 
     * @param label
     *            the label to configure.
     */
    public static void configureLabelAsHyperlink(JLabel label) {
        if (label == null) {
            return;
        }

        StringBuffer html = new StringBuffer();
        html.append("<html><font color=\"blue\"><u>");
        html.append(label.getText());
        html.append("</u></font></html>");

        label.setText(html.toString());
        label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
}