Reputation: 323
When setting a border to a JPanel (in my case Titled border + Line border, but also appears on some other borders, the background color of JPanel will spill out making it look ugly as hell. Here's a demonstration:
The only way i can make it look normal is to create another JPanel behind this one, make it white and make this one transparent:
So is there a way i can fix this or is it just how Swing works?
By the way, for changing background of a JPanel, i call
panel.setBackground(Color.WHITE);
,
To set the border i call
panel.setBorder(new TitledBorder(new LineBorder(new Color(169, 169, 169)), "Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null));
and as LaF, i use Windows10's LaF.
Upvotes: 1
Views: 883
Reputation: 18792
The Title is part of the JPanel
so the area behind it is painted with the background color.
Using TitledBorder.BELOW_TOP
makes it look like:
Upvotes: 2