In my main class i have built a JFrame and added functionality to a button which gets stock values from yahoos sites. Im currently storing the stock values in an arraylist and passing it to the other class, but thats not the problem. My problem is i dont know how to call the "paintComponent" method from my frame, because of the "Graphics g" variable. I think im missing the big picture here, am i on the right tracks or should i be looking to solve this problem some other way?
here is my graph class:
public class graph {
private static Main main;
public void paintComponent(Graphics g) {
Graphics2D graph2 = (Graphics2D)g;
graph2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
ArrayList<String> first = main.getFirst();
int x1 = 0;
int x2= 1;
for (String x : first) {
String[] parts = x.split(",");
int y1 = Integer.parseInt(parts[0]);
int y2= Integer.parseInt(parts[1]);
Shape drawLine = new Line2D.Float(y1, x1, y2, x2);
graph2.draw(drawLine);
}
}
}