Search code examples
javagraphicsrounded-corners

Java - Draw rectangle with two rounded corners


I need to draw a rectangle with the top-left and bottom-left corners, and another rectangle with the top-right and bottom-right corners, rounded. I know you can draw a rounded rectangle using Graphics2D#drawRoundRect, but that rounds all four corners.


Solution

  • I think this question haves an answer here https://stackoverflow.com/a/20321954/4443053

    Basically, you need to define your own shape. I-m pretty sure you can modify that example to your needed corners.