Hi Dinesh,
if this is just an information dialog, try with native OOo controls -
it's quite cumbersome to make OOo dialog really modal. I don't know how
we solved this in LanguageTool (the code was long removed as we're not
using a Swing dialog to check text anyway) but this was some dirty
trick. It's easier to get an information dialog using XMessageBox like this:
...
final XMessageBoxFactory messageBoxFactory = (XMessageBoxFactory)
UnoRuntime
.queryInterface(XMessageBoxFactory.class,
parentWindowPeer.getToolkit());
final Rectangle messageBoxRectangle = new Rectangle();
final XMessageBox box = messageBoxFactory
.createMessageBox(
winPeer,
messageBoxRectangle,
"infobox",
0,
"Window Title",
"Some beautiful info");
box.execute();
...
You get parentWindowPeer like this:
final XModel model = (XModel) UnoRuntime.queryInterface(XModel.class,
getxComponent());
final XWindow parentWindow = model.getCurrentController().getFrame()
.getContainerWindow();
final XWindowPeer parentWindowPeer = (XWindowPeer) UnoRuntime
.queryInterface(XWindowPeer.class, parentWindow);
My getxComponent() looks like this:
private XComponent getxComponent() {
try {
final XMultiComponentFactory xMCF = xContext.getServiceManager();
final Object desktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
final XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
XDesktop.class, desktop);
final XComponent xComponent = xDesktop.getCurrentComponent();
return xComponent;
} catch (final Throwable t) {
showError(t);
return null;
}
}
and you should already get XComponentContext-type variable (here:
xContext) when initializing your class in OOo in Main().
Regards
Marcin
Dinesh Chothe pisze:
Hello, I have been making one extension using java. In this I
want to simply populate simple dialog with some message on menu items click
event.
I am able to get populate dialog but not getting it as Modal.
Because dont know how to provide parent Dialog's object.
JDialog d = *new* JDialog(parent);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]