How do I call a function with a graphics object from another class?
问题 I want to call paint() from main() but I need a parameter.I don't know which parameter to pass and I can't seem to use the Graphics object when I define g outside the parameters since it can't be initialized. I tried creating an object of the Graphics class in main() and then passing it as a parameter but then whenever I try to use g it gies me a nullException import java.util.*; import java.awt.*; import javax.swing.JFrame; class Boards extends Canvas { JFrame frame; void frame() { JFrame