I'm currently trying to make a game with Eclipse I have ran into one problem.
When I try and set a background color Nothing shows up, I think it's because "setBackground" is bug for me.
Is there another way instead of using "setBackground"?
package Default.Package; import javax.swing.*; import java.awt.*; public class AC extends JComponent { public void ContentPane() { setBackground(Color.PINK); } @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); Graphics2D g2d = (Graphics2D) g; //Begin drawing } public static void main(String[] args) { JFrame gui = new JFrame("Window Title"); AC cp = new AC(); gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gui.setSize(800, 600); gui.setResizable(false); gui.setLocationRelativeTo(null); gui.setContentPane(cp); gui.setVisible(true); } }