Just to simplify, I'll leave out the details to my code:
public class Theclass{ private short a,b; public Theclass(short a,short b){ } public void paintComponent(Graphics g){ super.paintComponent(g) System.out.println("a: "+a+" and b: "+b);//outputs: "a: 0 and b: 0" } public static void main(String[]args){ a=10; b=5; Theclass tc=new TheClass(a,b); } }
So why isn't my paintComponent reading these 2 variables? It draws other things. I'm guessing it's being called before main is called. How do i get it to run when i want it to, aka after the required variables and methods have been run so it knows what to do?