public class DrawablePanel extends JPanel {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(500,500);
frame.setLayout(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new DrawablePanel());
frame.setVisible(true);
}
public DrawablePanel(){
setBackground(Color.black);
}
public Color pickColor(){
Random rand = new Random();
int a = rand.nextInt(255)+0;
int b = rand.nextInt(255)+0;
int c = rand.nextInt(255)+0;
Color color = new Color(a,b,c);
return color;
}
}
I have no idea why the JPanel
is not showing up on the JFrame
.
I have attached an image of what it looks like when I run the code.