/** * Makes the label clickable or makes it unclickable. Clickable label features bold and underlined * text * * @param clickable Is the label clickable * @param action Action to be performed on click * @param rolloverIcon Icon to display on rollover * @since Jun 13, 2006 2:00:57 AM */ public void setClickable( final boolean clickable, final ActionListener action, final Icon rolloverIcon) { if (clickable) { // Set the action this.action = action; // Set the offIcon; this.offIcon = getIcon(); setIcon(offIcon); // Add a Mouse Listener addMouseListener(this); // Set the text (Undelined and Bolded) setText( new StringBuffer("<html><b><u>").append(getText()).append("</u></b></html>").toString()); // Set the rollover icon this.rolloverIcon = rolloverIcon; // Init the Color and Mouse Cursor setForeground(offColor); } else { // Set the action to null this.action = null; // Remove the Mouse Listener removeMouseListener(this); // Change the text back to normal final StringBuffer textBuffer = new StringBuffer(getText()); final int msgEnd = textBuffer.indexOf("</u></b></html>"); setText(textBuffer.substring(12, msgEnd)); // Set the rollover icon this.rolloverIcon = null; } // Repaint the Label repaint(); }