Using JOptionPane with Monkeybars

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.

Hi,

every dialog is modal (according to the javadocs). The first paramter
has nothing to do with it.

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.

If you hava a JFrame it is already a Java type and could be passed to
the dialog.

the JFrame,
from its own controller (and this seems to be by design; the view and
the controller are separated as far as possible).

That is the part I don’t understand. Could you post some runnable code ?

Regards
Roger

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs