Reputation: 3088
I want to have a dialog with only 3 buttons. I am coding in C# as well and there I can assign a DialogResult (OK, CANCEL, ABORT and many more)
What I want to ask: Is there a way to do this? I guess code from my side is not helpful. I guess the pressed button is not difficult, but to wait till the frame has been closed. I will write a pseudo-code what I want to achieve anyway. I am looking forward to hear your tips.
public int showDialog() {
pack();
setVisible(true);
waitForFirstClick()
return pressedButton == a? 0 : pressedbutton == b ? 1 : 2;
}
What I am looking is the equivilent to C# showDialog() MSDN showDialog
When I click on one button I want to close it and I want to customize it like hell if I want (you know, it's not about the 3 buttons, but also gaining knowledge.... I want to do such things I do in C# for years in java as well)
Upvotes: 0
Views: 580
Reputation: 11327
This type of dialog/buttons is not supported by JOptionPane, but you can create a custom dialog to implement your behaviour. Use undecorated JDialog, GridLayout (1 row and 3 columns) and 3 or 4 buttons without border.
Upvotes: 1