Group Box

From Apache OpenOffice Wiki
Jump to: navigation, search



The group box control com.sun.star.awt.UnoControlGroupBox creates a frame to visually group other controls together, such as option buttons and check boxes. Controls can be added to the group box at any time. The group box control does not provide any container functionality for other controls, it is merely a visual control, and is always transparent. The group box contains a label embedded within the border and is set by the Label property. Apache OpenOffice uses fixed lines Horizontal/Vertical Line Control to visually subdivide a dialog into logical control groups.

  public void insertGroupBox(int _nPosX, int _nPosY, int _nHeight, int _nWidth){
  try{
      // create a unique name by means of an own implementation...
      String sName = createUniqueName(m_xDlgModelNameContainer, "FrameControl");
 
      // create a controlmodel at the multiservicefactory of the dialog model... 
      Object oGBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlGroupBoxModel");
      XMultiPropertySet xGBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oGBModel);
 
      // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
      xGBModelMPSet.setPropertyValues(
      new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
      new Object[] { new Integer(80), sName, new Integer(106), new Integer(114), new Integer(100)});
 
      // The controlmodel is not really available until inserted to the Dialog container
      m_xDlgModelNameContainer.insertByName(sName, oGBModel);
 
      // The following property may also be set with XMultiPropertySet but we
      // use the XPropertySet interface merely for reasons of demonstration 
      XPropertySet xGBPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oGBModel);
      xGBPSet.setPropertyValue("Label", "~My GroupBox");
  }catch (com.sun.star.uno.Exception ex){
      /* perform individual exception handling here.
       * Possible exception types are:
       * com.sun.star.lang.IllegalArgumentException,
       * com.sun.star.lang.WrappedTargetException,
       * com.sun.star.container.ElementExistException,
       * com.sun.star.beans.PropertyVetoException,
       * com.sun.star.beans.UnknownPropertyException,
       * com.sun.star.uno.Exception
       */
      ex.printStackTrace(System.out);
  }}
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages