简体   繁体   中英

Java draw line with border

I'm developing a JApplet in which the user can draw some lines over an image. Lines can be red or green, but I need to highlight them because I don't know the background color.

So I thought that I can draw a white "border" to the line, and I tried to do this creating other two white lines to the left and to the rigth of the original one. But the result is poor.

Is there a better way to accomplish this goal?

As mentioned by @Jesper, draw the line first using a thicker Stroke (as seen in this answer ).

The black outline on the letters has width 2.

g.setStroke(new BasicStroke(2f));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM