home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap21
/
ScrollbarApplet.java
< prev
Wrap
Text File
|
1996-03-07
|
1KB
|
46 lines
import java.awt.*;
import java.applet.*;
public class ScrollbarApplet extends Applet
{
Scrollbar scrollbar;
String s;
public void init()
{
BorderLayout layout = new BorderLayout();
setLayout(layout);
scrollbar = new Scrollbar(Scrollbar.HORIZONTAL,
50, 0, 1, 100);
add("North", scrollbar);
s = "50";
Font font = new Font("TimesRoman", Font.BOLD, 72);
setFont(font);
resize(200, 200);
}
public void paint(Graphics g)
{
g.drawString(s, 60, 120);
}
public boolean handleEvent(Event evt)
{
if (evt.target instanceof Scrollbar)
{
scrollbar = (Scrollbar)evt.target;
int value = scrollbar.getValue();
s = String.valueOf(value);
repaint();
return true;
}
else
{
boolean result = super.handleEvent(evt);
return result;
}
}
}