I tried to create an array of my custom buttons, and add it as an option in showOptionDialog
and it's actually worked out but the problem is now they don't behave like a normal yes_no buttons. What should i do to them so they would work exactly like a default one?
Here is my custom button class:
public class MenuButton extends JButton {
MenuButton(String text) {
super(text);
setBorder(null);
setContentAreaFilled(false);
//setBackground(new Color(153,0,0));
}
}
Buttons:
MenuButton yes = new MenuButton("Yes");
MenuButton no = new MenuButton("no");
MenuButton[] yes_no = {yes, no};
And method where i am using OptionDialog:
void confirmExit() {
int exitDecision = JOptionPane.showOptionDialog(Menu.this, "Are you sure?", ":(",
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, yes_no, yes_no[1]);
if(exitDecision == 0) { setVisible(false); dispose(); }
}