home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
promain.bin
/
DBVPO.DLL
/
SOURCE
/
JAVABEAN
< prev
next >
Wrap
Text File
|
1998-03-18
|
1KB
|
73 lines
/*
Basic Java Bean.
*/
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
public class JavaBean extends Canvas implements java.io.Serializable
{
public JavaBean()
{
super();
setSize(40,40);
enableEvents(MouseEvent.MOUSE_EVENT_MASK);
}
public void paint(Graphics context)
{
if (down)
{
context.setColor(pressedColor);
}
else
{
context.setColor(releasedColor);
}
context.fillArc(5,5,getSize().width-10,getSize().height-10,0,360);
}
protected void processMouseEvent (MouseEvent e)
{
switch(e.getID())
{
case MouseEvent.MOUSE_PRESSED:
down = true;
repaint();
break;
case MouseEvent.MOUSE_RELEASED:
down = false;
repaint();
break;
}
super.processMouseEvent(e);
}
public synchronized Color getReleasedColor()
{
return releasedColor;
}
public void setReleasedColor (Color newColor)
{
releasedColor = newColor;
repaint();
}
public synchronized Color getPressedColor()
{
return pressedColor;
}
public void setPressedColor (Color newColor)
{
pressedColor = newColor;
repaint();
}
private Color pressedColor = Color.black;
private Color releasedColor = Color.red;
transient boolean down = false;
}