import java.awt.Graphics; public class JParabola extends JOxy { private double a, b, c; public JParabola() { setA(1.0); setB(0.0); setC(0.0); } @Override public void paintComponent(Graphics g) { super.paintComponent(g); int w = getWidth() - 1; double x0 = 0.0, y0 = 0.0; for (int i = 0; i < w; i++) { double x = xr(i); double y = getA() * x * x + getB() * x + getC(); if (i == 0) { x0 = x; y0 = y; } else { g.drawLine(xg(x0), yg(y0), xg(x), yg(y)); x0 = x; y0 = y; } } } public double getA() { return a; } public final void setA(double a) { this.a = a; repaint(); } public double getB() { return b; } public final void setB(double b) { this.b = b; repaint(); } public double getC() { return c; } public final void setC(double c) { this.c = c; repaint(); } }