I am just starting out with Monkeybars. I want to create modal dialog
boxes, though only simple ones (eg confirm to quit). Java already has
this done with JOptionPane, but I cannot get it to be modal.
I have my event handler in the controller, which calls
showConfirmDialog, say like this (which is not going to actually do
anything with the result, but this is just to illustrate):
def quit_menu_item_action_performed
javax.swing.JOptionPane.showConfirmDialog(nil,
“Do you really want to quit?”,
“Confirmation”,
javax.swing.JOptionPane::YES_NO_OPTION,
javax.swing.JOptionPane::QUESTION_MESSAGE)
end
This works fine, displaying the dialog, but it is not modal. I think the
problem is that the first parameter is nil. It needs the parent
component.
My problem here is two-fold. Firstly the Ruby type has to become a Java
type. I think JRuby may be able to do that on its own. The big problem
is that I see to have to access to the parent component, the JFrame,
from its own controller (and this seems to be by design; the view and
the controller are separated as far as possible).
So is there a way around this? Any help appreciated.