S O U R C E C O D E
/ 1999 / 03
/ java
/ 1.lst
// Customized highlight title applet -- Williams
// Original applet by Anibal Wainstein of Demicron software, Sweden
import hilitetitle;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
// Customize the applet
public class custhilite extends hilitetitle
{
public void init() // applet initialization
{
// let the real applet initialize
super.init();
// listen for mouse click
addMouseListener(
new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
// When mouse clicks, jump to URL, if available
String url=getParameter("URL");
try {
URL urlo= new URL(url);
getAppletContext().showDocument(urlo);
} catch (MalformedURLException ignore) { }; // ignore
}
}
);
}
// Paint the applet
public void paint(Graphics g)
{
// call original paint
super.paint(g);
// see if border is requested
String param=getParameter("Border");
if (param==null) param="Y"; // default
if (param.length()==0 ||
param.equalsIgnoreCase("Y")||
param.equals("1")||
param.equalsIgnoreCase("yes"))
{
// draw our custom border
Dimension d=getSize(); // JDK 1.1
int clr;
// Get color from parameter
param=getParameter("BorderColor");
if (param==null)
clr=0xFF0000; // red default
else
clr=Integer.parseInt(param,16);
Color c= new Color(clr);
g.setColor(c);
g.drawRect(0,0,d.width-1,d.height-1);
}
}
// provide default parameter
public String getParameter(String name)
{
if (name.equals("font")) // could do others
{
String s=super.getParameter(name);
if (s==null) return "Helvetica"; else return s;
}
return super.getParameter(name);
}
}
|
home
|
current issue
|
archives
|
source code
|
demo express
|
events
|
search
|
editorial calendar
|
advertising
|
customer service
|
author guidelines
|
jobs
|
about
Entire contents copyright 1996-2000 CMP Media Inc.
Read our privacy policy.