//******************************************************************************
// -----------------------------------------------------------
// testLabel.java
// -----------------------------------------------------------
// Comments : simple linkLabel bean test
// -----------------------------------------------------------
// Author : R. BERTHOU
// E-Mail : rbl@berthou.com
// URL : http://www.javaside.com
// -----------------------------------------------------------
// 1.00 * R.BERTHOU * 09/10/2000 * samples tips
//******************************************************************************
// Importations
import java.awt.* ;
import java.awt.event.* ;
import java.net.URL ;
import rblBeans.linkLabel ;
public class testLabel extends java.applet.Applet
implements ActionListener
{
// Initialisation de l'applet
public void init() {
// create 1st label with link to http://www.javaside.com and change bgcolor
linkLabel l0 = new linkLabel("Javaside", "http://www.javaside.com/", Color.blue, Color.yellow) ;
l0.setFont(new Font("Dialog", Font.BOLD, 12));
add( l0 ) ;
l0.addActionListener(this);
// create 2nd label with link to http://www.aspside.com
l0 = new linkLabel("Aspside", "http://www.aspside.com/") ;
add( l0 ) ;
l0.addActionListener(this);
}
/**
* actionPerformed : received ActionEvent from linkLabel
*
* @param : ActionEvent e
*/
public void actionPerformed(ActionEvent e) {
String s = ((linkLabel)e.getSource()).getURL() ;
URL u ;
try{
if (s.startsWith("http:") || s.startsWith("ftp:") || s.startsWith("mailto:"))
u = new URL(s) ;
else
u = new URL(getCodeBase(),s) ;
getAppletContext().showDocument(u, "_blank");
} catch(Exception ex) {
return ;
}
}
}
Generated by srcColor