+ 1
Drawing background in Java
Hi, guys! I’m now learning how to create pictures in Java and feeling a little confused about backgrounds. Can anyone advise me some method to fill background with a color??
4 odpowiedzi
+ 1
I found this at https://stackoverflow.com/questions/4219919/how-to-change-the-background-color-on-a-java-panel
You could call:
getContentPane().setBackground(Color.black);
Or add a JPanel to the JFrame your using. Then add your components to the JPanel. This will allow you to call
setBackground(Color.black);
on the JPanel to set the background color
+ 1
Ok. For Java documentation https://docs.oracle.com/javase/7/docs/api/
0
Wallace Tomason, thank you for the answer! JPanel is already added to the JFrame, so I think setBackground will work. Actually I want to try set gradient as the background :)
0
Ok, thank you!