java 图形用户界面
importjava.awt.*;importjava.awt.event.*;classframe1extendsFrameimplementsActionListen...
import java.awt.*;
import java.awt.event.*;
class frame1 extends Frame implements ActionListener,WindowListener
{ Button but1;
Button but2;
TextArea t1;
frame1()
{
Frame f=new Frame("这是一个窗口");
f.setLayout(new BorderLayout());
Button but1= new Button("确定");
Button but2= new Button("取消");
Panel p1=new Panel();
p1.add(but1);
p1.add(but2);
TextArea t1=new TextArea();
f.add("North",p1);
f.add("Center",t1);
f.setSize(300,500);
f.setVisible(true);
but1.addActionListener(this);
but2.addActionListener(this);
f.addWindowListener(this);
}
public void actionPerfoemed(ActionEvent e)
{
if(e.getSource()==but1)
{
t1.setText("你单击了确定按钮");
}
else if(e.getSource()==but2)
{
t1.setText("你单击了取消按钮");
}
}
public void windowOpened(WindowEvent e)
{
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public void windowClosed(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowDeiconified(WindowEvent e)
{
}
public void windowActivated(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
}
public static void main(String[] args)
{
frame1 ff = new frame1();
}
}
我运行后会提示frame1不是抽象的,并且未覆盖java.awt.event.ActionLister中的抽象方法actionPerformed<java.awt.event.ActionEvent> class frame.extends Frame implements ActionListener.WindowListener.这个是什么原因。看不明白。
程序运行后会出现Exception in thread"main" java.lang.NoClassDefFpindError:frame?为什么? 展开
import java.awt.event.*;
class frame1 extends Frame implements ActionListener,WindowListener
{ Button but1;
Button but2;
TextArea t1;
frame1()
{
Frame f=new Frame("这是一个窗口");
f.setLayout(new BorderLayout());
Button but1= new Button("确定");
Button but2= new Button("取消");
Panel p1=new Panel();
p1.add(but1);
p1.add(but2);
TextArea t1=new TextArea();
f.add("North",p1);
f.add("Center",t1);
f.setSize(300,500);
f.setVisible(true);
but1.addActionListener(this);
but2.addActionListener(this);
f.addWindowListener(this);
}
public void actionPerfoemed(ActionEvent e)
{
if(e.getSource()==but1)
{
t1.setText("你单击了确定按钮");
}
else if(e.getSource()==but2)
{
t1.setText("你单击了取消按钮");
}
}
public void windowOpened(WindowEvent e)
{
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public void windowClosed(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowDeiconified(WindowEvent e)
{
}
public void windowActivated(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
}
public static void main(String[] args)
{
frame1 ff = new frame1();
}
}
我运行后会提示frame1不是抽象的,并且未覆盖java.awt.event.ActionLister中的抽象方法actionPerformed<java.awt.event.ActionEvent> class frame.extends Frame implements ActionListener.WindowListener.这个是什么原因。看不明白。
程序运行后会出现Exception in thread"main" java.lang.NoClassDefFpindError:frame?为什么? 展开
展开全部
是拼错了 ,其它的都没什么问题!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
en
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询