I have a RoundPanel class that extends JPanel and provides a rounded appearance.
JPanel user_icon = new RoundPanel(8);
user_icon.setBackground(Color.decode("#363b41"));
user_icon.setBorder(null);
user_icon.setBounds(160, 135, 40, 46);
container.add(user_icon);
user_icon.setLayout(null);
public class RoundPanel extends JPanel {
private static final long serialVersionUID = 1L;
private Shape shape;
public RoundPanel(int size) {
setOpaque(false);
}
protected void paintComponent(Graphics g) {
g.setColor(getBackground());
g.fillRoundRect(0, 0, getWidth()-1, getHeight()-1, 8, 8);
super.paintComponent(g);
}
protected void paintBorder(Graphics g) {
g.drawRoundRect(0, 0, getWidth()-1, getHeight()-1, 8, 8);
}
public boolean contains(int x, int y) {
if (shape == null || !shape.getBounds().equals(getBounds())) {
shape = new RoundRectangle2D.Float(0, 0, getWidth()-1, getHeight()-1, 8, 8);
}
return shape.contains(x, y);
}
}
want to modify it to have only the left corners rounded. (Half rounded, Half none)
I would, strongly, recommend taking the time to read through Working with Geometry, actually, I also recommend taking the time to read through the entire 2D Graphics trail while you're at it.
No one example/solution will ever meet your requirements 100%, you need to be prepared to put in the time to try different solutions and adapt the ones you like to your needs, this is the mark of a good developer.
So, with a little bit of experimentation (and a lot of reading through my previous answers) I was able to come up with...
I suggest having a look at Drawing a curve in Java using mouse drag, as working with Bézier curve always confuses me.
You may also consider look at: