File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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: 371
JComponent is not opaque and does not draw its background. JPanel is opaque and is recommend as base class for creating own components.
 
Don't get me started about those stupid light bulbs.
 
subject: can't understand JComponent
 
Similar Threads
Help w/ displaying several .PNG files
I want to insert Data into the pie chart.I have put the code to gernate the Pie
Messagebox with Mouseevent
paintComponent JPanel