//FrameDemo。java
//在網頁中彈出JFame容器的窗口
//2009-11-8
//<applet code=FrameDemo width=200 height=100>
//</applet>
import javax.swing.*;
import java.awt.*;
class PopupWindow extends JFrame
{
JButton
button1=new JButton("button1"),
button2=new JButton("button2");
PopupWindow(String title){
super(title);
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
cp.add(button1);
cp.add(button2);
}
}
public class FrameDemo extends JApplet
{
JButton
button3=new JButton("button3"),
button4=new JButton("button4");
public void init(){
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
cp.add(button3);
cp.add(button4);
PopupWindow pw=new PopupWindow("Popup window");
pw.setSize(300,300); //set window size
pw.setVisible(true); //set window visible
}
}