3

What I've got here is a JPanel with a rounded border that is set up as such:

panel.setBorder(new LineBorder(PanelColor, 5, true));

The problem is, in each of the corners there are 2 diagonal opaque lines going from the outer corner to the inner corner that is the length of the border. Whatever is behind the border shows through. Is there any way to get rid of these lines and make the entire border one solid color? Thanks!

I'd attach a picture but I don't have enough rep to do so :P

Doug
  • 47
  • 1
  • 2
  • 7
  • *"I'd attach a picture but I don't have enough rep to do so"* You can always upload the image to an image hosting site and include a link. If it is a good description of the problem, and not too large in pixels or bytes, someone else might embed it into the question for you. See also [How do I create a screenshot to illustrate a post?](http://meta.stackexchange.com/questions/99734/how-do-i-create-a-screenshot-to-illustrate-a-post/) (hopefully to soon become part of the SE FAQ) for tips on making screenshots. – Andrew Thompson Jul 28 '11 at 10:14

2 Answers2

5

Maybe here is a way to paint RoundedLineBorder; please be careful with constants for nice output to the GUI.

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • 1
    Huh, this fixed the problem I just had to change drawRoundRect to fillRoundRect in order to have the whole border a solid color. Why on earth the default rounded border would not work like this I do not know. Thanks for the help! – Doug Jul 25 '11 at 20:55
  • 1
    @Doug you are welcome, that's about compound Border (Empty + Line), which covered corners up-to 2-3pixels – mKorbel Jul 25 '11 at 20:58
0

Your problem may be that the background panel is white and your foreground panel is PanelColor and since you are rounding out the edges you are seeing the white background behind your foreground panel.

Grammin
  • 11,808
  • 22
  • 80
  • 138
  • Yes this is true, whatever is behind the rounded panel shows through. I have other colored panels that can be moved around and when they are place beneath the panel with the rounded edges their colors show up instead of the white lines. I should have made it clear that they're not always white. – Doug Jul 25 '11 at 20:42