home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
win95
/
sieciowe
/
hotja32.lzh
/
hotjava
/
doc
/
appguide
/
classes
/
appwithattribute.java
< prev
next >
Wrap
Text File
|
1995-05-19
|
813b
|
34 lines
import browser.Applet;
import awt.Color;
import awt.Graphics;
class AppWithAttribute extends Applet {
Color textColor=null;
public void init() {
String color = getAttribute("color");
if (color != null) {
System.out.println("The color is: " + color);
// We only handle white and red, for now.
if (color.equals("white"))
textColor = awt.Color.white;
else if (color.equals("red"))
textColor = awt.Color.red;
}
else
System.out.println("No valid color was specified");
resize(150, 25);
}
public void paint(Graphics g) {
if (textColor != null) {
g.setForeground(textColor);
}
g.drawString("Hello world!", 50, 25);
}
}