编程题:标签1的字号碧比文本框的字号大,单击按钮是若文本框中的数正确,则标签2文显示 正确 否则 显示 不正确。
下面是我 写的,编译有错误,我实在是找不到了,谢谢各位帮我找找~~import java.awt.*;
import java.awt.event.*;
public class p140_1 extends Frame implements ActionListener{
static Label l1,l2,l3;
static TextField t;
static Button b;
static Panel p1,p2,p3,p4;
static int n1=15;
static int n2=20;
public static void main(String[] args){
p140_1 my=new p140_1();
p1=new Panel();
p2=new Panel();
p3=new Panel();
p4=new Panel();
b=new Button("OK");
l1=new Label("6+9=");
l2=new Label("正确");
l3=new Label("不正确");
t=new TextField(" ");
my.add("Nouth",p1);
my.add("Wast",p2);
my.add("East",p3);
my.add("South",p4);
p1.add(l1);
p2.add(t);
p3.add();
p4.add(b);
my.setSize(300,150);
my.setVisible(true);
b.addActionListener(new p140_1());
}
public void actionPerformed(ActionEvent e){
if(6+9==15)
{
t.setText(n1.getText());
p3.setText(l2.getText());
}
else { t.setText(n2.getText());
p3.setText(l3.getText());}
}
}
下面是我 写的,编译有错误,我实在是找不到了,谢谢各位帮我找找~~import java.awt.*;
import java.awt.event.*;
public class p140_1 extends Frame implements ActionListener{
static Label l1,l2,l3;
static TextField t;
static Button b;
static Panel p1,p2,p3,p4;
static int n1=15;
static int n2=20;
public static void main(String[] args){
p140_1 my=new p140_1();
p1=new Panel();
p2=new Panel();
p3=new Panel();
p4=new Panel();
b=new Button("OK");
l1=new Label("6+9=");
l2=new Label("正确");
l3=new Label("不正确");
t=new TextField(" ");
my.add("Nouth",p1);
my.add("Wast",p2);
my.add("East",p3);
my.add("South",p4);
p1.add(l1);
p2.add(t);
p3.add();
p4.add(b);
my.setSize(300,150);
my.setVisible(true);
b.addActionListener(new p140_1());
}
public void actionPerformed(ActionEvent e){
if(6+9==15)
{
t.setText(n1.getText());
p3.setText(l2.getText());
}
else { t.setText(n2.getText());
p3.setText(l3.getText());}
}
}
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;public class p140_1 extends JFrame implements ActionListener {
static Label l1, l2, l3;
static TextField t;
static JButton b;
static Panel p1, p2, p3, p4;
static int n1 = 15;
static int n2 = 20;
public static void main(String[] args) {
p140_1 my = new p140_1();
p1 = new Panel();
p2 = new Panel();
p3 = new Panel();
p4 = new Panel();
b = new JButton("OK");
l1 = new Label("6+9=");
//l2 = new Label("正确");
//l3 = new Label("不正确");
t = new TextField();
my.add("North", p1);
//my.add("West", p2);
my.add("Center", p3);
my.add("South", p4);
p1.setLayout(new FlowLayout());
p1.add(l1);
p1.add(t);
//p2.add(t);
//p3.add();
p4.add(b);
my.setSize(300, 150);
my.setVisible(true);
b.addActionListener(new p140_1());
JButton b2 = new JButton("正确");
JButton b3 = new JButton("错误");
p3.add(b3);
p3.add(b2);
} public void actionPerformed(ActionEvent e) {
if (Integer.parseInt(t.getText()) == 15) {
//t.setText(n1+"");
} else {
//t.setText(n2+"");
}
}
}
import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import javax.swing.JButton;
import javax.swing.JFrame; public class p140_1 extends JFrame implements ActionListener {
static Label l1;
static Label l2;
//static Label l3;static TextField t;
static JButton b;
static Panel p1;
//static Panel p2;
static Panel p3;
static Panel p4;
static int n1 = 15;
//static int n2 = 20;
public static void main(String[] args) {
p140_1 my = new p140_1();
p1 = new Panel();
//p2 = new Panel();
p3 = new Panel();
p4 = new Panel();
b = new JButton("OK");
l1 = new Label("6+9="); l2 = new Label(" ");
//l3 = new Label("不正确");
t = new TextField();
my.add("North", p1);
//my.add("West", p2);
my.add("Center", p3);
my.add("South", p4);
p1.setLayout(new FlowLayout());
p1.add(l1);
p1.add(t);
//p2.add(t);
//p3.add();
p4.add(b);
my.setSize(300, 150);
my.setVisible(true);
b.addActionListener(new p140_1());
//JButton b2 = new JButton("正确");
//JButton b3 = new JButton("错误");
//p3.add(b3);
//p3.add(b2);
} public void actionPerformed(ActionEvent e) {
if (Integer.parseInt(t.getText()) == 15) {
l2.setText("正确");
p3.add(l2);;
p3.repaint();
} else {
l2.setText("不正确");
p3.add(l2);;
p3.repaint();
}
}
}