Hi together,
I wrote a little XDialog showing two radio buttons. But now
I have the
problem, that I don't know how to find out which radio
Button was
selected when the OK Button is pressed. Can you tell me
where to start.
Documentation about this theme is very less on the internet.
Greetings, Tobias
Here is my code:
-----%<-----
// insert the control models into the dialog
model
XNameContainer xNameCont = (XNameContainer)
UnoRuntime.queryInterface(
XNameContainer.class, dialogModel);
xNameCont.insertByName(_buttonName,
buttonModel);
xNameCont.insertByName(_radioPrint01,
printPages01);
xNameCont.insertByName(_radioPrint02,
printPages02);
xNameCont.insertByName(_labelName, labelModel);
xNameCont.insertByName(_cancelButtonName,
cancelButtonModel);
// create the dialog control and set the model
Object dialog =
xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.awt.UnoControlDialog",
xComponentContext );
XControl xControl = ( XControl
)UnoRuntime.queryInterface(
XControl.class, dialog );
XControlModel xControlModel = ( XControlModel
)UnoRuntime.queryInterface(
XControlModel.class, dialogModel );
xControl.setModel( xControlModel );
// add an action listener to the button control
XControlContainer xControlCont = (
XControlContainer
)UnoRuntime.queryInterface(
XControlContainer.class, dialog );
Object objectButton = xControlCont.getControl(
"OK" );
XButton xButton = ( XButton
)UnoRuntime.queryInterface(
XButton.class, objectButton );
xButton.addActionListener( new
ActionListenerImpl(
xControlCont ) );
// create a peer
Object toolkit =
xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.awt.ExtToolkit",
xComponentContext );
XToolkit xToolkit = ( XToolkit
)UnoRuntime.queryInterface(
XToolkit.class, toolkit );
XWindow xWindow = ( XWindow
)UnoRuntime.queryInterface(
XWindow.class, xControl );
xWindow.setVisible( false );
xControl.createPeer( xToolkit, null );
// execute the dialog
XDialog xDialog = ( XDialog
)UnoRuntime.queryInterface(
XDialog.class, dialog );
xDialog.execute();
// dispose the dialog
XComponent xComponent = ( XComponent
)UnoRuntime.queryInterface(
XComponent.class, dialog );
xComponent.dispose();
-----%<-----
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|