In Swing JPanel said to be opaque, what does that mean?
Also how JPanel VS JComponent compared in relation to opaque?
Please explain if possible in simple terms, hence i am not very experienced in GUI programming.
Thanks in advance for your help
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Opaque has a very specific meaning in Swing – it means that the component fully paints the full area within its bounds (see the setOpaque javadoc)
This is used primarily to determine whether it is necessary to repaint components behind the current component.
unnecessary to repaint anything
behind the component (since it would
just be overwritten), hence such
background drawing may be omitted as
an optimisation.
that the component is implementing some transparency
effects – e.g. drawing a component that has a semi-transparent window in the middle, or drawing a non-rectangular component
If you are creating your own JComponent and setOpaque to true but do not honour the contract (i.e. you do not draw the full area within the bounds despite claiming to be opaque) then you may get unexpected results due to the background not being redrawn.