Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LineDrawer extends JPanel {
- public void paintComponent(Graphics g) {
- // clear background
- g.setColor(getBackground());
- g.fillRect(0, 0, getWidth(), getHeight());
- // ritar linjer:
- g.setColor(Color.BLACK);
- int lastX = 0;
- int lastY = 0;
- for (int x = 0; x < graphy1.size(); x++) {
- int y = graphy1.get(x);
- g.drawLine(lastX, lastY, x, y);
- lastX = x;
- lastY = y;
- }
- g.setColor(Color.RED);
- int lastX = 0;
- int lastY = 0;
- for (int u = 0; u < graphy2.size(); u++) {
- int y = graphy2.get(x);
- g.drawLine(lastX, lastY, u, y);
- lastX = u;
- lastY = y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement