Program.java
import java.awt.Dimension; import java.awt.Graphics; import java.lang.*; import javax.swing.*; public class Program{ public static void main(String[] args) { Main main = new Main(); JFrame frame = new JFrame("Title"); frame.add(main); frame.setVisible(true); frame.pack(); main.setup(); main.update(); } }
Main.java
import java.awt.Graphics; import java.util.concurrent.*; import java.lang.*; import javax.swing.*; import java.awt.Dimension; public class Main extends JPanel{ public void setup(){ } public void update(){ while(true){ try{ TimeUnit.MILLISECONDS.sleep(16); frame.repaint(); }catch(Exception E){} } } public void draw(Graphics g){ } public Dimension getPreferredSize() { return new Dimension(500, 500); } //override stuff public void paintComponent(Graphics g) { super.paintComponent(g); draw(g); } }
the problem is that I cannot access frame.repaint() in Main.java, how do I fix it? I prefer simple, beginner friendly looking code, not making AAA game.