public void show(Graphics g) { // System.out.println("Showing ..."); Bar b = (Bar) getDisplayElement(s1); Rectangle r = new Rectangle(b.getLocation(), b.getSize()); r.y += r.height; Rectangle r2 = ((TextElement) getDisplayElement(s5)).fitToRect(g, "SansSerif", Font.PLAIN, r); r2.y += r2.height; ((TextElement) getDisplayElement(s6)).fitToRect(g, "SansSerif", Font.PLAIN, r2); super.show(g); }
public void actionPerformed(ActionEvent evt) { graph.setColor(Color.cyan); graph.fillRect(0, 0, SIZE.width, SIZE.height); bar.draw(graph); for (int i = 0; i < balls.length; i++) balls[i].draw(graph); repaint(); }
public void run() { while (running) { try { Thread.sleep(SPEED); } catch (InterruptedException e) { } synchronized (pos) { pos.translate(dx, dy); } if (pos.x < 0 || pos.x > Cwiczenie5_4.SIZE.width - SIZE) dx = -dx; if (dy > 0 && bar.bump(pos)) dy = -dy; if (pos.y < 0) dy = -dy; if (pos.y > Cwiczenie5_4.SIZE.height - SIZE) { running = false; } } }