Java BFS Algorithm - Trying to paint nodes on JPanel
问题 I've just implemented a BFS and DFS algorithm. My ultimate goal is to animate the algorithm onto a JPanel... But firstly I'd like to paint the nodes to the screen in their respective parent-child relationship: So far I've been able to achieve: My paint component is as follows: public void paintComponent(Graphics g) { ArrayList<Nodes> nodePrintList = new ArrayList<Nodes>(); g.setColor(Color.WHITE); g.fillRect(0, 0, width, height); int x = 50, y = 50; //if currentNode has no more children, move