如何将这个程序修改成求两个数的最大公约数和最小公倍数
import java.awt.*;import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class Quad_Gui_1 extends JFrame implements ActionListener
{ private JTextField a=new JTextField(10);
private JTextField b=new JTextField(10);
private JTextField c=new JTextField(10);
private JLabel r=new JLabel("求根一元二次方程的根");
private JLabel A=new JLabel("A:");
private JLabel B=new JLabel("B:");
private JLabel C=new JLabel("C:");
private JLabel x1=new JLabel();
private JLabel x2=new JLabel();
private JLabel X1=new JLabel("X1:");
private JLabel X2=new JLabel("X2:");
private JButton js=new JButton("jisuan");
public Quad_Gui_1()
{ super("Quad");
JPanel contentPane=(JPanel)getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel p1=new JPanel();
JPanel p2=new JPanel(new GridLayout(0,2));
JPanel p3=new JPanel();
contentPane.setBorder(new EmptyBorder(10,10,10,10));
p1.add(r,BorderLayout.CENTER);
p2.add(A);
p2.add(a);
p2.add(B);
p2.add(b);
p2.add(C);
p2.add(c);
p2.add(X1);
p2.add(x1);
p2.add(X2);
p2.add(x2);
p3.add(js,BorderLayout.NORTH);
js.addActionListener(this);
contentPane.add(p1,BorderLayout.NORTH);
contentPane.add(p2,BorderLayout.CENTER);
contentPane.add(p3,BorderLayout.SOUTH);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent event)
{ String command=event.getActionCommand();
if(command.equals("jisuan"))
{ double a1=Double.parseDouble(a.getText().trim());
double b1=Double.parseDouble(b.getText().trim());
double c1=Double.parseDouble(c.getText().trim());
Quad q=new Quad(a1,b1,c1);
try
{ q.x1x2();
x1.setText(Double.toString(q.getX1()));
x2.setText(Double.toString(q.getX2()));
}catch(Exception e){
x1.setText("error");
x2.setText(" ");
}
}
}
public static void main(String arg[])
{ Quad_Gui_1 f;
f=new Quad_Gui_1();
}
}
补充:Java , Java相关