import java.awt.*;
importjava.awt.*;importjava.awt.event.*;publicclassFrame1extendsFramepublicFrame1()se...
import java.awt.*;
import java.awt.event.*;
public class Frame1 extends Frame
public Frame1()
setTitle("Frame1");
setLayout(new FlowLayout());
l1=new JLabel("1+1=");
add(l1);
txt1=new TextField(1);
add(txt1);
b1=new JButton("ok");
add(b1);
b2=new JButton("cacel");
add(b2);
l2=new JLabel("Your answer is:");
add(l2);
l3=new JLabel(" init ");
add(l3);
setResizable(false);
}
Label l1;
TextField txt1;
Label l2;
Button b1;
Button b2;
Label l3;
public static void main(String args[]) {
Frame1 nowFrame=new Frame1();
nowFrame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
nowFrame.pack();
nowFrame.show();
}
}
找出错误的改过来
在线等!!! 展开
import java.awt.event.*;
public class Frame1 extends Frame
public Frame1()
setTitle("Frame1");
setLayout(new FlowLayout());
l1=new JLabel("1+1=");
add(l1);
txt1=new TextField(1);
add(txt1);
b1=new JButton("ok");
add(b1);
b2=new JButton("cacel");
add(b2);
l2=new JLabel("Your answer is:");
add(l2);
l3=new JLabel(" init ");
add(l3);
setResizable(false);
}
Label l1;
TextField txt1;
Label l2;
Button b1;
Button b2;
Label l3;
public static void main(String args[]) {
Frame1 nowFrame=new Frame1();
nowFrame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
nowFrame.pack();
nowFrame.show();
}
}
找出错误的改过来
在线等!!! 展开
1个回答
展开全部
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
//1.这里少个括号
// public class Test extends Frame
public class Test extends Frame {
// 2.这里也少括号
// public Test()
public Test() {
setTitle("Frame1");
setLayout(new FlowLayout());
// 3.这里不能将SWING的控件类型转换成AWT的类型
// l1=new JLabel("1+1=");
l1 = new Label("1+1=");
add(l1);
txt1 = new TextField(1);
add(txt1);
// 同3
b1 = new Button("ok");
add(b1);
// 同3
b2 = new Button("cacel");
add(b2);
// 同3
l2 = new Label("Your answer is:");
add(l2);
// 同3
l3 = new Label(" init ");
add(l3);
setResizable(false);
}
Label l1;
TextField txt1;
Label l2;
Button b1;
Button b2;
Label l3;
public static void main(String args[]) {
Test nowFrame = new Test();
nowFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
nowFrame.pack();
nowFrame.show();
}
}
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
//1.这里少个括号
// public class Test extends Frame
public class Test extends Frame {
// 2.这里也少括号
// public Test()
public Test() {
setTitle("Frame1");
setLayout(new FlowLayout());
// 3.这里不能将SWING的控件类型转换成AWT的类型
// l1=new JLabel("1+1=");
l1 = new Label("1+1=");
add(l1);
txt1 = new TextField(1);
add(txt1);
// 同3
b1 = new Button("ok");
add(b1);
// 同3
b2 = new Button("cacel");
add(b2);
// 同3
l2 = new Label("Your answer is:");
add(l2);
// 同3
l3 = new Label(" init ");
add(l3);
setResizable(false);
}
Label l1;
TextField txt1;
Label l2;
Button b1;
Button b2;
Label l3;
public static void main(String args[]) {
Test nowFrame = new Test();
nowFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
nowFrame.pack();
nowFrame.show();
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |