code: public short showMessageBox(XWindowPeer _xParentWindowPeer, String _sTitle, String _sMessage, String _aType, int _aButtons) {
          short nResult = -1;
          XComponent xComponent = null;
          try {
              Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
              XMessageBoxFactory xMessageBoxFactory = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit);
              // rectangle may be empty if position is in the center of the parent peer
              Rectangle aRectangle = new Rectangle();
              XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(_xParentWindowPeer, aRectangle, _aType, _aButtons, _sTitle, _sMessage);
              xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMessageBox);
              if (xMessageBox != null) {
                  nResult = xMessageBox.execute();
              }
          } catch (com.sun.star.uno.Exception ex) {
              ex.printStackTrace(System.out);
          } finally {
              //make sure always to dispose the component and free the memory!
              if (xComponent != null) {
                  xComponent.dispose();
              }
          }
          return nResult;
      }
docs: Shows an messagebox
  @param _xParentWindowPeer the windowpeer of the parent window
  @param _sTitle the title of the messagebox
  @param _sMessage the message of the messagebox
  @param _aType string which determines the message box type: (infobox|warningbox|errorbox|querybox|messbox)
  @param _aButtons MessageBoxButtons which buttons should be available on the message box