List Info

Thread: How to get the state of a radio button on a XDialog in Java




How to get the state of a radio button on a XDialog in Java
user name
2006-12-20 20:38:15
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-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

How to get the state of a radio button on a XDialog in Java
user name
2006-12-20 22:16:03
Hi Tobias,

Tobias Krais wrote:

> 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.

In OOoBasic the getState of a radio-button returns Ttrue if
it is selected.
Maybe this helps a little.

Regards,
Cor
-- 

Cor Nouws
Arnhem - Netherlands
nl.OpenOffice.org - marketing contact

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

How to get the state of a radio button on a XDialog in Java
user name
2006-12-23 17:15:33
Hi Cor,

>> 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.
> 
> In OOoBasic the getState of a radio-button returns
Ttrue if it is selected.
> Maybe this helps a little.

thank you for your help! Here it is in Java:
-----%<-----
XControlContainer xControlCont = (XControlContainer)
	UnoRuntime.queryInterface(XControlContainer.class,
		dialogObject);
Object objectButton =
xControlCont.getControl(_radioPrint01);
XRadioButton xButton = (XRadioButton)
UnoRuntime.queryInterface(
	XRadioButton.class, objectButton);
xButton.getState();
-----%<-----

Greetings, Tobias

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )