Search code examples
javaswinggraphicspaintjlayeredpane

Java: JLayeredPane and Lines or Circles


I have the following Problem: I have a JLayeredPane and I need to add a Circle and some Lines to it. The Problem wit the Lines is, that they should be able to be redrawn/to move position (The Lines Symbolize some moving Vectors) When I just add some GLines to the Graphics JLayeredPane.getGraphics() they are permanent. Or is there any possibility to Redraw the JLayeredPane.getGraphics()?

Please Help!


Solution

  • LinePanel shows one approach, but it can be adapted to any Shape. For many lines, your program might maintain a List<Shape>. In any case the example may serve as a foundation for your sscce.