home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap23
/
FrameApplet2.java
< prev
next >
Wrap
Text File
|
1996-03-06
|
913b
|
47 lines
import java.awt.*;
import java.applet.*;
public class FrameApplet2 extends Applet
{
CustomFrame frame;
Button button;
public void init()
{
frame = new CustomFrame("Custom Frame Window");
button = new Button("Show Window");
add(button);
}
public boolean action(Event evt, Object arg)
{
boolean visible = frame.isShowing();
if (visible)
{
frame.hide();
button.setLabel("Show Window");
}
else
{
frame.show();
button.setLabel("Hide Window");
}
return true;
}
}
class CustomFrame extends Frame
{
CustomFrame(String title)
{
super(title);
}
public void paint(Graphics g)
{
resize(200, 100);
g.drawString("This is a custom window.", 30, 30);
}
}