Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

[Graphics2D] Drawing double rounded corners border.  RSS feed

 
Doru Chiulan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am struggling to make a double border which has rounded corners. The border should be 2 parallel lines.

I made something which looks almost good, but if you look closer there are a few wrong things.
To achieve this, I made 2 paths, then painted them in 2 different colours.

The main problem is painting with AA, because the colours overlap and are affected.

I think it would be smoother to paint a single path using 2 colours.

For the first problem, I think some kind of a stroke would be enough. But, if I build a stroke, it's almost same thing like drawing the path twice, like I did before. Anyway i think that would fix AA problem. But still, maybe I can achieve a smoother effect for the corners.

Question:

Do you think there is other solution which is better than what I tried ?
Maybe something with a 2x1 Texture ? It's possible to achieve this ? I know I tried this before and when a curve was encountered the direction of the texture was wrong and looked messy.

Thank you!

PS: Ignore the blueish thing, it's a dragged component to activate the highlight border.
Screenshot from 2014-03-26 16:20:51.png
[Thumbnail for Screenshot from 2014-03-26 16:20:51.png]
 
Rob Camick
Ranch Hand
Posts: 2753
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you can use a CompoundBorder. See the Swing tutorial on How to Use Borders for some examples.

Post your SSCCE that demonstrates the problem, maybe someone can off some advice.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!