I need make a JTabbedPane like this (I made the image in Photoshop):
But in my look and feel (based on TabbedPaneUI: javax.swing.plaf.basic.BasicTabbedPaneUI) looks like this:
How can I do it?
I’ve tried change LAF properties, but I didn’t find a solution.
If I use setBorder method the swing make this:
jtabbedpane1.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1, true));
Java changed only the upper left corner as outer border as image above shows.
I need a solution that might use the Paint method on an extended JTabbedPane class, but I really don’t know if this is correct or how do this.
3
Answers
I read the tutorial above and tried override paintComponent method in my extended JTabbedPane class, see:
The result:
https://i.imgur.com/YLXkVRS.jpg
Rounded corners are actually a boolean argument when instantiating a border, as can be seen here with BorderFactory.
So what we can do is something like this:
Where “true” refers to rounded corners.
If you are interested in customizing the border further, you will most likely have to paint it yourself, in which case I would look here for a further read.
Edit regarding your code:
etc. where you repeat for each corner that you want your L shape at.
Here is the start of an answer.
Somethings to note, The inner panel the ones holding the jlabel have square corners. I’ve shown this by making
one
white. I’ve taken some of the boundary code from BasicTabbedPaneUI source code.They really did not make this easy to manage, but looking at the source for the MetalTabbedPaneUI you can see they draw each border as a line, and it would need to be modified to draw a curve at the ends.