4
votes

Does anyone have a coded implementation of SplitButton?

I've tried searching some implementations but none of them work. (e.g. JSplitButton).

2
Every implementation I've seen doesn't transpose will across UIs - MadProgrammer
what's wrong with it? Note I didn't try the one you linked to - but for any reasonable suggestion it would be useful to know waht exactly you aren't satisfied with :-) - kleopatra
I can't click the arrow button. I just run the included demo and it doesn't work. Try it. - user1551085
For anyone searching for a simple single-file implementation in 2020. I found one originally posted by MadProgrammer and modified it to work for me with FlatLaf L&F, but it seems to work rather well with others too. Link to StackOverflow question ![Component image](i.stack.imgur.com/zAMue.png) - DUDSS

2 Answers

4
votes

Demo not working != splitButton not working :-)

splitButton = new JSplitButton("Split Button Demo");
splitButton.setPopupMenu(jPopupMenu2);
add(splitButton);

(Note: this is not a recommendation of that particular splitButton implementation, just a reminder that you should be a bit more careful in evaluating the projects you are finding. If you can't for some reason, you might consider using a commercial product, like Synthetica or JIDE, just to name two)

0
votes

You should try using a JComboBox. They work for more than just simple drop down, but it should do the trick.