本帖最后由 饶正林 于 2013-4-25 08:41 编辑
- /*
- <applet coed="checkBox.class" width=400 height=400></applet>
- */
- import java.awt.*;
- import java.awt.event.*;
- import java.applet.*;
- public class checkBox extends Applet implements ItemListener
- {
- String msg="";
- Checkbox Win98,WinNT,Linux,mac;
- public void init()
- {
- setLayout(new FlowLayout(FlowLayout.LEFT));
- Win98=new Checkbox("Win98",null,true);
- WinNT=new Checkbox("WinNT");
- Linux=new Checkbox("Linux");
- mac=new Checkbox("mac");
- add(Win98);
- add(WinNT);
- add(Linux);
- add(mac);
- Win98.addItemListener(this);
- WinNT.addItemListener(this);
- Linux.addItemListener(this);
- mac.addItemListener(this);
- }
- public void itemStateChanged(ItemEvent ie)
- {
- repaint();
- }
- public void paint(Graphics g)
- {
- msg="current state:";
- g.drawString(msg,6,80);
- msg="Win98"+Win98.getState();
- g.drawString(msg,6,100);
- msg="WinNT"+WinNT.getState();
- g.drawString(msg,6,120);
- msg="Linux"+Linux.getState();
- g.drawString(msg,6,140);
- msg="mac"+mac.getState();
- g.drawString(msg,6,160);
- }
- }
复制代码 -->javac checkBox.java
-->appletviewer checkBox.java
后为何出现:警告: <applet> 标记需要代码属性? |
|