aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes can't understand JComponent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "can Watch "can New topic
Author

can't understand JComponent

budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
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
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
JComponent is not opaque and does not draw its background. JPanel is opaque and is recommend as base class for creating own components.
 
Consider Paul's rocket mass heater.
 
subject: can't understand JComponent