I'm building a simulator that is trying to display an ArrayList of Node objects and I'm using an enhanced for loop in the overridden paintComponent of my JComponent responsible for drawing to the center of my screen.
package networkSimulation;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
public class mainComponent extends JComponent{
public void paintComponent(Graphics g){
NetworkGUI.updateForWindowSize();
g.drawLine(-50, (int)NetworkGUI.windowHeight - 130, (int)NetworkGUI.windowWidth + 50, (int)NetworkGUI.windowHeight - 130);
g.fillOval(100, 100, 100, 100);
//Draw the contents of the graph
for(Node node: NetworkGUI.graph.getNodes()){
System.out.println("Drawing a Node at " + node.getX() + ',' + node.getY());
g.fillOval((int)node.getX(), (int)node.getY(), 100, 100);
}
}
}
Currently the print in my loop is printing correctly, but the oval isn't appearing. However, the oval set to draw outside of the loop is working fine. Any insight as to what I might be doing wrong would be greatly appreciated. Thank you in advance.