import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Work3 { public stati
MyActionaction=newMyAction();这编译是个错误请求高手解答啊importjava.applet.*;importjavax.swing.*;im...
MyAction action=new MyAction(); 这编译是个错误 请求高手解答啊
import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Work3 {public static void main(String[] args) {new Applet();}}
class Applet{JTextField jtf1 = new JTextField(10);JTextField jtf2 = new JTextField(10);
JTextField jtf3 = new JTextField(10);Applet(){JFrame jf=new JFrame("加法");jf.setSize(350,300);jf.setVisible(true);Container con=jf.getContentPane();con.add(mPanel());}public JPanel mPanel(){JPanel main= new JPanel();JPanel panel1= new JPanel();JLabel label1=new JLabel("第一个整数");panel1.add(label1);panel1.add(jtf1);JPanel panel2=new JPanel();JLabel label2=new JLabel("第二个整数");panel1.add(label2);panel1.add(jtf2);JPanel panel3= new JPanel();JButton jb =new JButton("相加为");
MyAction action=new MyAction();
jb.addActionListener(action);
panel3.add(jb);
JPanel panel4=new JPanel();
panel4.add(jtf3);
main.add(panel1);
main.add(panel2);
main.add(panel3);
main.add(panel4);
return main;
}
} 展开
import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Work3 {public static void main(String[] args) {new Applet();}}
class Applet{JTextField jtf1 = new JTextField(10);JTextField jtf2 = new JTextField(10);
JTextField jtf3 = new JTextField(10);Applet(){JFrame jf=new JFrame("加法");jf.setSize(350,300);jf.setVisible(true);Container con=jf.getContentPane();con.add(mPanel());}public JPanel mPanel(){JPanel main= new JPanel();JPanel panel1= new JPanel();JLabel label1=new JLabel("第一个整数");panel1.add(label1);panel1.add(jtf1);JPanel panel2=new JPanel();JLabel label2=new JLabel("第二个整数");panel1.add(label2);panel1.add(jtf2);JPanel panel3= new JPanel();JButton jb =new JButton("相加为");
MyAction action=new MyAction();
jb.addActionListener(action);
panel3.add(jb);
JPanel panel4=new JPanel();
panel4.add(jtf3);
main.add(panel1);
main.add(panel2);
main.add(panel3);
main.add(panel4);
return main;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询