import java.awt.*;
class ChoiceTest3 extends Frame {
Choice names = new Choice( );
//通过 add() 方法可以添加项目
ChoiceTest3(String title) {
super(title);
names.add( "尤" );
names.add( "吴" );
names.add( "陈" );
names.add( "马" );
names.add( "耿" );
add( names );
}
public static void main(String args[])
{
ChoiceTest3 y=new ChoiceTest3( "姓名选择框" );
y.setLayout(new FlowLayout());
y.setSize(400,250);
y.show();
}
}
[此贴子已经被作者于2006-8-1 11:11:48编辑过]
----------------解决方案--------------------------------------------------------
程序运行提示:
java.lang.NoClassDefFoundError: AAATest
Exception in thread "main"
----------------解决方案--------------------------------------------------------
等了 半天没人回个帖 不过错误 找到了 呵呵
----------------解决方案--------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
class ChoiceTest extends Frame implements WindowListener {
Choice names = new Choice( );
//通过 add() 方法可以添加项目
ChoiceTest(String title) {
super(title);
names.add( "尤炜" );
names.add( "吴志兵" );
names.add( "陈贝" );
names.add( "马万里" );
names.add( "耿玉鹏" );
add( names );
//y.addWindowListener(this);
}
public void f( ){
ChoiceTest y = new ChoiceTest( "姓名选择框" );
y.setLayout(new FlowLayout());
y.setSize(400,250);
y.show();
y.addWindowListener(this);//添加一个关闭事件
}
public void windowClosing(WindowEvent e) { System.exit(-1); }
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
}
public class ABC {
public static void main(String args[])
{
ABC abc = new ABC();
abc.f();
}
}
大家再看一下 还是刚才的程序 不过我想加一个关闭窗口的事件 请问该怎么加
----------------解决方案--------------------------------------------------------
怎么没人来看看啊....
----------------解决方案--------------------------------------------------------
你要问什么问题啊?
你第一个贴也不是applet啊!!!
----------------解决方案--------------------------------------------------------
我这个不是一个下拉框嘛 现在我想给他加一个关闭事件 请问该怎么加
----------------解决方案--------------------------------------------------------
System.exit(0);
是这个意思?!
----------------解决方案--------------------------------------------------------
你那个不行 程序一启动就关了 我加好了 程序如下 不知道还有没有更方便的方法
import java.awt.*;
import java.awt.event.*;
class ChoiceTest extends Frame implements WindowListener {
Choice names = new Choice( );
//通过 add() 方法可以添加项目
ChoiceTest(String title) {
super(title);
names.add( "尤" );
names.add( "吴" );
names.add( "陈" );
names.add( "马" );
names.add( "耿" );
add( names );
addWindowListener(this);
}
public static void main(String args[] ){
ChoiceTest y = new ChoiceTest( "姓名选择框" );
y.setLayout(new FlowLayout());
y.setSize(400,250);
y.show();
}
public void windowClosing(WindowEvent e) { System.exit(-1); }
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
}
----------------解决方案--------------------------------------------------------