Reputation: 6309
When I use JOptionPane
, the options are contained in a drop-down menu.
But I want the options are listed as buttons, so that the user can directly click the buttons without clicking the drop-down button first.
My current code:
newHero.setFaction((Faction) JOptionPane.showInputDialog(null,
message,
title,
JOptionPane.INFORMATION_MESSAGE,
null,
myChoices,
myChoices[0]
));
How do I display the options as buttons in a arrangement similar to FlowLayout
?
Upvotes: 1
Views: 343
Reputation: 347184
Try using a option dialog instead of an input dialog...
String[] myChoices = {"Always", "Yes", "No", "Never"};
JOptionPane.showOptionDialog(
null,
"Happy",
"Happy",
JOptionPane.OK_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
myChoices,
myChoices[0]);
Upvotes: 1