Difference between revisions of "Documentation/DevGuide/GUI/Horizontal Vertical Line Control"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
 
Line 11: Line 11:
  
 
This example inserts a line with a horizontal orientation (Orientation == 0) in a dialog:
 
This example inserts a line with a horizontal orientation (Orientation == 0) in a dialog:
<source lang="java">
+
<syntaxhighlight lang="java">
 
   public void insertHorizontalFixedLine(int _nPosX, int _nPosY, int _nWidth, String _sLabel){
 
   public void insertHorizontalFixedLine(int _nPosX, int _nPosY, int _nWidth, String _sLabel){
 
   try{
 
   try{
Line 45: Line 45:
 
       ex.printStackTrace(System.out);
 
       ex.printStackTrace(System.out);
 
   }}
 
   }}
</source>
+
</syntaxhighlight>
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Graphical User Interfaces]]
 
[[Category:Documentation/Developer's Guide/Graphical User Interfaces]]

Latest revision as of 12:45, 22 December 2020



The line control service com.sun.star.awt.UnoControlFixedLine describes the behavior of simple lines in a dialog. In most cases, the line control is used to visually subdivide a dialog. The line control may provide horizontal or vertical orientation which is determined by the Orientation property of the model as specified in com.sun.star.awt.UnoControlFixedLineModel. The label of a line control is set by the Label property. The label is only displayed if the control has a horizontal orientation.

This example inserts a line with a horizontal orientation (Orientation == 0) in a dialog:

  public void insertHorizontalFixedLine(int _nPosX, int _nPosY, int _nWidth, String _sLabel){
  try{
      // create a unique name by means of an own implementation...
      String sName = createUniqueName(m_xDlgModelNameContainer, "FixedLine");
 
      // create a controlmodel at the multiservicefactory of the dialog model... 
      Object oFLModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedLineModel");
      XMultiPropertySet xFLModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFLModel);
 
      // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
      xFLModelMPSet.setPropertyValues(
      new String[] {"Height", "Name", "Orientation", "PositionX", "PositionY", "Width"},
      new Object[] { new Integer(2), sName, new Integer(0), new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
 
      // The controlmodel is not really available until inserted to the Dialog container
      m_xDlgModelNameContainer.insertByName(sName, oFLModel);
 
      // The following property may also be set with XMultiPropertySet but we
      // use the XPropertySet interface merely for reasons of demonstration 
      XPropertySet xFLPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFLModel);
      xFLPSet.setPropertyValue("Label", _sLabel);
  }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