Class UIButton

All Implemented Interfaces:
IBackReferenceProvider, EventListener, IFocusComp, ILockUI, IMessageBox, IUIPanelAnimation, IComponent, ICustomDataProvider, IGProp<GProp<?>[]>, IPropCnr, IUIAction, IUIActionHolder, IUIComp, IUIContextMenuOwner, IUIFocusComp, IUIHTMLTextComponent, IUITextComponent, IVSActionListener, IVSComponentListener, IVSComponentState, IVSFieldListener, Cloneable
Direct Known Subclasses:
EUIButton

public class UIButton extends AbstractUIAction implements IUIFocusComp, IUIHTMLTextComponent, IUIContextMenuOwner
Button UI component.
Author:
Christopher Mindus
  • Field Details

    • PN_TEXT_WRAP

      public static final String PN_TEXT_WRAP
      Property name for the text wrap "tw".
      See Also:
    • TEXT_WRAP_MULTIPLE

      public static final int TEXT_WRAP_MULTIPLE
      Text wrap: the text wraps over multiple lines when the button is narrower than its text, and the height of the button follows its lines.
      See Also:
    • TEXT_WRAP_SINGLE

      public static final int TEXT_WRAP_SINGLE
      Text wrap: the text is on a single line (the default) and the button is as wide as its text.
      See Also:
    • TEXT_WRAP_ELLIPSIS

      public static final int TEXT_WRAP_ELLIPSIS
      Text wrap: the text is on a single line and is cut with an ellipsis when the button is narrower than its text.
      See Also:
    • TEXT_WRAP_DEFAULT

      public static final int TEXT_WRAP_DEFAULT
      The text wrap of a button that has none of its own, i.e. whose property PN_TEXT_WRAP is absent: TEXT_WRAP_SINGLE, a single line. This constant is the ONE place of the default in Java: getTextWrap() answers it for an absent property and for a stored value that is none of the three, and setTextWrap(int) removes the property for it.

      A change of this constant changes every button that has no Text wrap of its own, in every application and without a change of any panel file. It is a decision of the product, not a setting of an application: a designer chooses the Text wrap of a button, never the default. The client holds the same value in TEXT_WRAP_DEFAULT of iz/ui/UIButton.js and iiziGo's row in buttonTextWrap.d of PanelEditor.properties; the three are changed together, and the test ButtonTextWrapDefaultTest of com.iizix.js.tests fails when they differ.

      See Also:
  • Constructor Details

    • UIButton

      public UIButton()
      Creates the component without a name. The name must be set in all cases using the setPropertyAtom call.
    • UIButton

      public UIButton(Atom propertyAtom)
      Creates the component with the specified name. All system-reserved names for components begins with "$".
      Parameters:
      propertyAtom - the name of the component, unique within it's parent.
    • UIButton

      public UIButton(Atom propertyAtom, GProp<?>[] newValue) throws PropException
      Creates the component with the specified name, initialized to contain the GProp items. All system-reserved names for components begins with "$".
      Parameters:
      propertyAtom - The name of the component, unique within it's parent.
      newValue - The array of all properties the component should have.
      Throws:
      PropException - when at least one of the properties to initialize the component with is invalid.
  • Method Details

    • clone

      public UIButton clone()
      Clones the UIButton.
      Overrides:
      clone in class AbstractUIAction
      Returns:
      A cloned instance of the UIButton.
    • getDeviceType

      public final int getDeviceType()
      Gets the device type: -1=mobile, 0=both, 1=desktop.
      Specified by:
      getDeviceType in interface IUIComp
    • isMobileContextMenuSupported

      public boolean isMobileContextMenuSupported()
      Returns if the component can show the context menu in mobile mode.
      Specified by:
      isMobileContextMenuSupported in interface IUIContextMenuOwner
      Returns:
      Button component supports context menus for mobile.
    • setTextWrap

      public boolean setTextWrap(int type)
      Sets the text wrap, i.e. how the text of the button is processed when the button is narrower than its text: on a single line (the default), wrapped over multiple lines, or on a single line cut with an ellipsis. The values are those of the label type of UILabel.setLabelType(int), without "fill" (the text of a button is centered).

      On a single line the text never wraps and the button is as wide as its text. With multiple lines the height of the button follows its lines in every layout manager. With the ellipsis the full text is shown as the tooltip of the button while it is cut, unless the button has a title or a tooltip of its own.

      The single line is the default from version 5.1, and the property is then absent. Before that version the text of every button wrapped when the button was narrower than its text: a button that relies on it is set to TEXT_WRAP_MULTIPLE. The default is TEXT_WRAP_DEFAULT, in that one place.

      Parameters:
      type - TEXT_WRAP_SINGLE (1) = single line, TEXT_WRAP_MULTIPLE (0) = multiple lines, TEXT_WRAP_ELLIPSIS (2) = single line with an ellipsis, -1 = the default, TEXT_WRAP_DEFAULT. The default, given as -1 or as its value, removes the property: a panel file carries it only when it differs from the default.
      Returns:
      true for change, false for no change.
      Throws:
      IllegalArgumentException - if the type is none of the values above.
    • getTextWrap

      public int getTextWrap()
      Gets the text wrap of the button, see setTextWrap(int).
      Returns:
      TEXT_WRAP_MULTIPLE (0), TEXT_WRAP_SINGLE (1) or TEXT_WRAP_ELLIPSIS (2) when the property holds that value, the default TEXT_WRAP_DEFAULT otherwise: the property is absent or holds a value that is none of the three.
    • getApproximateSize

      public Size getApproximateSize()
      Returns the size of the component in pixels. The size is a calculation and does not exactly reflect the real size that may be different due to additional styles not taken into account by this method. The size is calculated from the font of the component and default or defined values (such as character length or number of lines for text area).
      Specified by:
      getApproximateSize in class UIComp
      Returns:
      The size of the component.
      Throws:
      IllegalStateException - If called outside of the Designer, e.g. from the Server.