import java.awt.*;
import java.awt.event.*;
class GEquation extends Frame implements ActionListener { TextField fa, fb, fc, fx1, fx2; Button btn; public GEquation() { this.setLayout(new FlowLayout()); fa = new TextField(8); fb = new TextField(8); fc = new TextField(8); fx1 = new TextField(20); fx2 = new TextField(20); add(fa); add(fb); add(fc); btn = new Button(\ add(btn); add(fx1); add(fx2); this.setSize(200,200); this.setVisible(true); } public void actionPerformed(ActionEvent e) { double a = Double.parseDouble(fa.getText()); double b = Double.parseDouble(fb.getText()); double c = Double.parseDouble(fc.getText()); Equation e1 = new Equation(a, b, c); if (e1.getDelta() >= 0) { fx1.setText(Double.toString(e1.getRootage1())); fx2.setText(Double.toString(e1.getRootage2())); } if (e1.getDelta() < 0) { fx1.setText(\无解\ fx2.setText(\ } } }
public class testGEquation { public static void main(String[] args) { GEquation ge=new GEquation(); } }