public XTextComponent addTextField ( String content , String name , int x , int y , int width , int height ) throws Exception { Object labelModel = multiServiceFactory . createInstance ( "com.sun.star.awt.UnoControlEditModel" ) ; XPropertySet textFieldProperties = ( XPropertySet ) UnoRuntime . queryInterface ( XPropertySet . class , labelModel ) ; textFieldProperties . setPropertyValue ( "PositionX" , new Integer ( x ) ) ; textFieldProperties . setPropertyValue ( "PositionY" , new Integer ( y ) ) ; textFieldProperties . setPropertyValue ( "Width" , new Integer ( width ) ) ; textFieldProperties . setPropertyValue ( "Height" , new Integer ( height ) ) ; textFieldProperties . setPropertyValue ( "Name" , name ) ; textFieldProperties . setPropertyValue ( "TabIndex" , new Short ( ( short ) tabcount ++ ) ) ; textFieldProperties . setPropertyValue ( "MultiLine" , new Boolean ( false ) ) ; textFieldProperties . setPropertyValue ( "Text" , content ) ; // insert the control models into the dialog model this . nameContainer . insertByName ( name , labelModel ) ; XControlContainer controlContainer = ( XControlContainer ) UnoRuntime . queryInterface ( XControlContainer . class , this . oUnoDialog ) ; Object obj = controlContainer . getControl ( name ) ; XTextComponent field = ( XTextComponent ) UnoRuntime . queryInterface ( XTextComponent . class , obj ) ; return field ; }
Create a single line textfield with the given content .