帮忙看看这个JAVA程序哪儿错了?

来源:百度知道 编辑:UC知道 时间:2024/06/30 04:57:52
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
class WindowList extends Frame implements ItemListener, ActionListener {
List list;
Label label;
TextField text;
TextArea area;
Button add, del, delall;
Checkbox box1, box2;
CheckboxGroup group;
WindowList()
{ setLayout(new FlowLayout());
label = new Label("标题");
list = new List();
text = new TextField(8);
area = new TextArea(6, 25);
add = new Button("添加");
del = new Button("删除");
group = new CheckboxGroup();
delall = new Button("全部删除");
box1 = new Checkbox("单选", true, group);
box2 = new Checkbox("多选", false, group);
add.addActionListener(this);
text.addActionListener(this);
del.addActionListener(this);
delall.addActionListener(this);
list.addItemListener(this);
box1.addItemListene

最后的public class应该放在最外层定义,上面的代码把zouye2的定义错误的放在了WindowList类定义里面,拿到外面来就OK了

//zuoye2没必要做这样的类
需要添加退出按钮
括号有点乱

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testgraphics;

import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;

class WindowList extends Frame implements ItemListener, ActionListener {

List list;
Label label;
TextField text;
TextArea area;
Button add, del, delall;
Checkbox box1, box2;
CheckboxGroup group;
Button btnExit;
WindowList() {
setLayout(new FlowLayout());
label = new Label("标题");
list = new List();
text = new TextField(8);
area = new TextArea(6, 25);
add = new Button("添加");
del = new Button("删除");