i was making a jcomponent and inside it i drew a rectangle . i wanted to set the background color of the JComponent as red or anything but when i write setBackground(Color.red) and execute the code the color is not set . Can somebody explain why ? My hunch is that it has something to do with the opaque property . Please expalin. here's the code
Hauke Ingmar Schmidt
posted 4 years ago
JComponent is not opaque and does not draw its background. JPanel is opaque and is recommend as base class for creating own components.