How to show a JOptionPane in JME?

Hello again my friends…  :smiley:

When I click in the screen of my monitor model, I would like to make show a Simple JOptionPane.showInputDialog, but I noticed that this is not possible to use directly on JME…

what I have to do???



I just want to show a JOptionPane with Input, that, if the user answer correctly, my screen monitor will change its texture to a certain image, and if its wrong, its change to another texture…



here's what I've done. I know that it is completely wrong, i'm just posting it here to you guys know where I want to make a JOptionPane shows up and verify if the String was correct…


//se o bot

something like JOptionPane.showInternalFrame???

how I do this?  :smiley:

after a lot of tries, I got the conclusion that you have to clear the panel first before you can dispose a frame… after doing this I can dispose my JMEDesktop without "bug" my game…

But like darkfrog said, it's not a good ideia to always dispose and create a new JMEDesktop, the I just set my jmeDesktop to be "CULL_ALWAYS" and when I need it again, I get the JPanel, clean it, and then reconstruct the Frame…



I think its the better solution…  ;)  :wink:

If someone has some trouble using JMEDesktop, the solution is already solved in the latest versions of it::



the method showDialog has inside the JOptionPane call: the only thing to do is to change it for the way we want it:

[move]For Example:[/move]



      private void showInputDialog() {
        final JDesktopPane desktopPane = jmeDesktop.getJDesktop();
        final JInternalFrame modalDialog = new JInternalFrame( "Input Dialog Message" );

        [b]JOptionPane optionPane = new JOptionPane(
              "The only way to close this dialog is byn"
              + "pressing one of the following buttons:n",
              JOptionPane.QUESTION_MESSAGE,
              JOptionPane.YES_NO_OPTION);[/b]

        modalDialog.getContentPane().add( optionPane );
        jmeDesktop.setModalComponent( modalDialog );
        desktopPane.add( modalDialog, 0 );
        modalDialog.setVisible( true );
        modalDialog.setSize( modalDialog.getPreferredSize() );
        modalDialog.setLocation( ( desktopPane.getWidth() - modalDialog.getWidth() ) / 2,
                ( desktopPane.getHeight() - modalDialog.getHeight() ) / 2 );
        jmeDesktop.setFocusOwner( optionPane );

        optionPane.addPropertyChangeListener( JOptionPane.VALUE_PROPERTY, new PropertyChangeListener() {
            public void propertyChange( PropertyChangeEvent evt ) {
                modalDialog.setVisible( false );
                jmeDesktop.setModalComponent( null );
                desktopPane.remove( modalDialog );
            }
        } );
       
        desktopPane.repaint();
        desktopPane.revalidate();
    }



8)