import java.awt.Color;import java.awt.Graphics;import java.awt.Point;import java.awt.event.KeyEvent;import java.awt.event.KeyListener;import java.awt.event.MouseEvent;import java.awt.event.MouseMotionListener;import java.util.Iterator;import java.util.LinkedList;import javax.swing.JPanel;public class DrawingPanel extends JPanel implements MouseMotionListener,KeyListener { LinkedList zug = null; LinkedList sammlung[]; //FEHLER "," expected sammlung = new LinkedList[100]; int index = 0; public DrawingPanel() { addKeyListener(this); addMouseMotionListener(this); setFocusable(true); } public void mouseDragged(MouseEvent e) { System.out.println("Maus gezogen:" + e.getPoint()); if(zug==null) { zug = new LinkedList(); zug.add(e.getPoint()); repaint(); } if(zug!=null) { zug.add(e.getPoint()); repaint(); } } public void mouseMoved(MouseEvent e) { System.out.println("Maus ohne Taste bewegt"); if(zug!=null){ sammlung[index].add(zug); System.out.println("schleife"); index+=1; } zug=null; } public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE: System.out.println("ESC-pressed"); break; case KeyEvent.VK_DOWN: System.out.println("DOWN pressed"); break; case KeyEvent.VK_UP: System.out.println("UP pressed"); case KeyEvent.VK_DELETE: System.out.println("Delete pressed"); break; case KeyEvent.VK_END: System.out.println("End pressed"); break; case KeyEvent.VK_HOME: System.out.println("Pos1 pressed"); break; default: System.out.println("pressed: " + e.getKeyCode()); break; } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } public void paintZug(Graphics g, LinkedList z) { for(int i=1;i<z.size();i++ ) { Point m = (Point)z.get(i-1); Point n = (Point)z.get(i); g.drawLine(m.x,m.y , n.x,n.y); } } protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.RED); g.drawLine(10, 30, 100, 30); g.setColor(Color.BLACK); g.drawLine(20, 20, 20, 100); for(int i = 0; i<index;i++) paintZug(g,sammlung[i]); } }