Consider extracting the code for directly drawing of the arrows and nodes out of JPanel. Perhaps you can create an Arrow and a Node class that know how to draw themselves, for instance that has a public void paint(Graphics g)
method.
Then you could create an ArrayList<Arrow>
and ArrayList<Node>
fields for your JPanel class, and draw both in the JPanel's paintComponent(...)
method by iterating through the Lists and calling each item's paint(...)
method passing in the Graphics context obtained from the JVM.
Otherwise, if you absolutely need to draw these in separate JPanels, one on top of the other, be sure that the top JPanel is not opaque via setOpaque(false)
, so that its background won't be painted, and you can see through it.
For more specific help, consider telling us more about your problem, your current code, and even posting some of your code, preferably in the form of an SSCCE (please see the link that describes this very useful construct).
Welcome to stackoverflow.com by the way!