我有一个程序用作实验来习惯 GUI。它基本上采用 f(x)=ax^2+bx+c 形式的二次方,并找到实数零点、y 截距和对称轴。它在计算和所有方面都运行良好。我的问题是我创建了一个不可编辑的文本框(使用窗口构建器SWT应用程序),无论我做什么,它总是在一行上打印所有内容!\n 不起作用,\r\n 不起作用...请帮助。
Button btnNewButton = new Button(shlParacalc, SWT.NONE);
btnNewButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String aval = alphabox.getText();
double a = Double.parseDouble(aval);
String bval = betabox.getText();
double b = Double.parseDouble(bval);
String cval = gammabox.getText();
double c = Double.parseDouble(cval);
CalcLib mathObj = new CalcLib();
double yint = mathObj.yIntercept(a, b, c);
double axis = mathObj.Axis(a, b);
double zero[] = mathObj.Zero(a, b, c);
outputbox.append("y-intercept = " + yint); // these four lines need
outputbox.append("axis of symmetry = " + axis); //to be printed
outputbox.append("1st zero = " + zero[0]); //on individual lines
outputbox.append("2nd zero = " + zero[1]);