Question

I believe it's a popular topic but i still want to ask an advise.

I want to make all of JButtons from Swing with rounded corners, and there seem to be at least 3 ways to do so.

1)I can create my own Look and feel based on synth L&F, where all buttons will be shown with rounded borders, but it seems to be like shooting the flies with cannon so...

2)I thought of extending JButton class and making all buttons with rounded corners, it's very easy, but, although i don't have any memory restrictions i think it is still too much to load a whole new class in Java just for this borders... And as i've seen it, there are no interfaces that i can use instead of extending JButton.

3)And for the last solution i can just iterate through all of my JButton components after the GUI was created and call something like a setBorder(new MyOwnRoundedBorder(int radius)); for each of them, but it doesn't seem very code frienldy to me.

Please help me find my way through this possible prejudicies.

Thank you in advance.

Was it helpful?

Solution

2) is no good Idea, as soon as you reuse existing components (i.e. file open dialogues) the original JButton is used.

3) same issue + maintenance problems

It seems you have to create your own look&feel

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top