一个APPLET程序,包括两个输入区和一个标签,用户输入两个整数,用DO-WHILE求最大公约数和最小公倍数

解决方案 »

  1.   


    package hugo;
    import java.awt.*; 
    import java.awt.event.*; 
    import javax.swing.*; public class Test {
    public static void main (String[] args) 

    new tMap("HUGO"); 


    class tMap extends JFrame 

    TextField t1 = new TextField(10);
    TextField t2 = new TextField(10);
    Button b = new Button("ok");
    TextField t3 = new TextField(10);
    TextField t4 = new TextField(10);
    tMap(String title) 

    super(title); 
    this.setLayout(new FlowLayout());
    this.add(t1);
    this.add(t2);
    this.add(b);
    this.add(t3);
    this.add(t4);
    b.addActionListener(new ActionListener1());
    setBounds(100,100,400,100); 
    setVisible(true); 

    class ActionListener1 implements ActionListener{
    public void actionPerformed(ActionEvent e){
    t3.setText("最大公约数"+getMax(t1.getText(),t2.getText()));
    t4.setText("最小公倍数"+getMim(t1.getText(),t2.getText()));
    }
    }}
    方法自己找来代进去就行了