Label Field

From Apache OpenOffice Wiki
Jump to: navigation, search

A label field control supports the service and the model displays descriptive texts that are not meant to be edited by the user, such as labels for list boxes and text fields. By default, the label field control is drawn without a border. The format of the text can be set by the properties as described in Font-specific Properties. Label controls can be used to assign shortcut keys for controls without labels that succeed the label field control. To assign a shortcut key to a control without a label such as a text field, the label field is used. The tilde (~) prefixes the corresponding character in the Labelproperty of the label field. A fixed text control cannot receive the focus, so the focus automatically moves to the next control in the tab order. It is important that the label field and the text field have consecutive tab indices.

The following example demonstrates how to create a UnoControlFixedText control. You can create all types of dialog controls in the same way as is shown in this example. This example assumes that a dialog has already been created as described in Instantiation of a Dialog. This example also shows how to add a mouse listener.

  public XFixedText insertFixedText(XMouseListener _xMouseListener, int _nPosX, int _nPosY, int _nWidth, int _nStep, String _sLabel){
  XFixedText xFixedText = null;
      // create a unique name by means of an own implementation...
      String sName = createUniqueName(m_xDlgModelNameContainer, "Label");
      // create a controlmodel at the multiservicefactory of the dialog model... 
      Object oFTModel = m_xMSFDialogModel.createInstance("");
      XMultiPropertySet xFTModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel);
      // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
      new String[] {"Height", "Name", "PositionX", "PositionY", "Step", "Width"},
      new Object[] { new Integer(8), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nStep), new Integer(_nWidth)});
      // add the model to the NameContainer of the dialog model
      m_xDlgModelNameContainer.insertByName(sName, oFTModel);
      // The following property may also be set with XMultiPropertySet but we
      // use the XPropertySet interface merely for reasons of demonstration
      XPropertySet xFTPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFTModel);
      xFTPSet.setPropertyValue("Label", _sLabel);
      // reference the control by the Name
      XControl xFTControl = m_xDlgContainer.getControl(sName);
      xFixedText = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, xFTControl);
      XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xFTControl);
  }catch ( ex){
      /* perform individual exception handling here.
       * Possible exception types are:
      return xFixedText;
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages