Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public class LineDrawer extends JPanel {
  2.  
  3. public void paintComponent(Graphics g) {
  4. // clear background
  5. g.setColor(getBackground());
  6. g.fillRect(0, 0, getWidth(), getHeight());
  7.  
  8. // ritar linjer:
  9. g.setColor(Color.BLACK);
  10. int lastX = 0;
  11. int lastY = 0;
  12. for (int x = 0; x < graphy1.size(); x++) {
  13. int y = graphy1.get(x);
  14. g.drawLine(lastX, lastY, x, y);
  15. lastX = x;
  16. lastY = y;
  17. }
  18. g.setColor(Color.RED);
  19. int lastX = 0;
  20. int lastY = 0;
  21. for (int u = 0; u < graphy2.size(); u++) {
  22. int y = graphy2.get(x);
  23. g.drawLine(lastX, lastY, u, y);
  24. lastX = u;
  25. lastY = y;
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement