Java: Drawing using Graphics outside the class which draws the main canvas
问题 I'm trying to develop a Tic Tac Toe game in Java using Graphics. My problem is: I don't want to add any other methods inside my Grid.class (which draws the lines 3x3), but i want to draw my X or O from a class called Game. My grid class looks like the following: import java.awt.Graphics; import javax.swing.JPanel; public class Grid extends JPanel{ private final int ITEM_WIDTH = 30; private final int ITEM_HEIGHT = 30; private final int OUTER_WIDTH = 90; private final int OUTER_HEIGHT = 90;