Ejemplo n.º 1
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   int maxWidth = getWidth();
   double hstep = (double) maxWidth / (double) points;
   int maxHeight = getHeight();
   for (int i = 0; i < points; i++)
     pts[i] = (int) (sines[i] * maxHeight / 2 * .95 + maxHeight / 2);
   g.setColor(Color.red);
   for (int i = 1; i < points; i++) {
     int x1 = (int) ((i - 1) * hstep);
     int x2 = (int) (i * hstep);
     int y1 = pts[i - 1];
     int y2 = pts[i];
     g.drawLine(x1, y1, x2, y2);
   }
 }
Ejemplo n.º 2
0
 public void paint(Graphics g) {
   s = "inits: " + inits + ", starts: " + starts + ", stops: " + stops;
   g.drawString(s, 10, 10);
 }