0

i build an desktop application java using NetBeans IDE 7.4 ,add CSS file from file->new file->other->Cascading Style Sheet . iam write a css :

JPanel{
  background: red ;
}

but there is no effect on JPanel background , where is the problem ?

3
  • Are you using a framework or just pure swing? Commented Feb 3, 2014 at 8:35
  • 1
    Then no, you cannot do that. So how do you include it in the java class? CSS are used to style documents written in markup language (e.g. HTML). Unless you have a framework that translates xml into Java Swing class then that may be possible. But in pure swing, no way. Commented Feb 3, 2014 at 8:54
  • Take a look at this thread Commented Feb 3, 2014 at 8:59

1 Answer 1

0

If your panel is 'not opaque' (transparent) you wont see your background color.

however read this

https://netbeans.org/kb/73/java/gui-image-display.html

Sign up to request clarification or add additional context in comments.

1 Comment

You have to call the super.paintComponent();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.