Reputation: 2165
I want to use JFrame to send system notification from my Java application, and I want set a background color at this notification. Now the notification works, but I'm not able to change the background color. This is the code:
public class NotificationFrame extends JFrame{
/**
*
*/
private static final long serialVersionUID = -2902763674924791105L;
public NotificationFrame(){
super();
setUndecorated(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBackground(Color.red);
setMinimumSize(new Dimension(300, 100));
add(new LabelFormat("Notifiche"));
}
}
With this code the background color of my JFrame is everty time Gray.
Upvotes: 2
Views: 2304
Reputation: 285403
You're actually wanting to change the JFrame's contentPane, not the JFrame itself.
Change
setBackground(Color.red);
to
getContentPane().setBackground(Color.red);
Upvotes: 7