Class TextIconData
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.components.tags.TextData
-
- net.sf.jguiraffe.gui.builder.components.tags.TextIconData
-
public class TextIconData extends TextData
A helper class that provides some functionality for components that can display both a text and an icon.
This class simply holds attribute values for defining a text and/or an icon. At least one of these elements must be specified. There are also some evaluation methods, e.g. for retrieving the final caption (which may involve a resource access).
Instances of this class are used by several tag classes for components that provide the functionality of displaying text and icons. Because some of these components are simple components and others are full featured input components it is not possible to place the functionality provided by this class in a common base class. Instead the delegation model has to be used.
- Version:
- $Id: TextIconData.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description TextIconData(FormBaseTag tag)
Creates an instance ofTextIconData
and associates it with the specified tag.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TextIconAlignment
getAlignment()
Returns the alignment of the icon relative to the text.String
getAlignmentString()
Returns the name of the current alignment.Object
getIcon()
Returns the icon object.char
getMnemonic()
Returns the mnemonic character.String
getMnemonicKey()
Returns the key code of the mnemonic.String
getMnemonicResID()
Returns the resource ID for the mnemonic.boolean
isDefined()
Checks whether this object is defined.void
setAlignment(TextIconAlignment alignment)
Sets the alignment of the icon relative to the text.void
setAlignmentString(String name)
Sets the alignment of the icon relative to the name as string.void
setIcon(Object icon)
Sets the icon object.void
setMnemonicKey(String mnemonicKey)
Sets the mnemonic's key code.void
setMnemonicResID(String mnemonicResID)
Sets the resource ID for the mnemonic.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.TextData
getCaption, getResgrp, getTag, getText, getTextres, setResgrp, setText, setTextres
-
-
-
-
Constructor Detail
-
TextIconData
public TextIconData(FormBaseTag tag)
Creates an instance ofTextIconData
and associates it with the specified tag.- Parameters:
tag
- the associated tag
-
-
Method Detail
-
getIcon
public Object getIcon()
Returns the icon object.- Returns:
- the icon (can be null )
-
setIcon
public void setIcon(Object icon)
Sets the icon object.- Parameters:
icon
- the icon
-
getAlignment
public TextIconAlignment getAlignment()
Returns the alignment of the icon relative to the text.- Returns:
- the alignment
-
setAlignment
public void setAlignment(TextIconAlignment alignment)
Sets the alignment of the icon relative to the text.- Parameters:
alignment
- the alignment (must not be null )
-
getAlignmentString
public String getAlignmentString()
Returns the name of the current alignment.- Returns:
- the alignment name
-
setAlignmentString
public void setAlignmentString(String name)
Sets the alignment of the icon relative to the name as string. The passed in string must be the name of one of the literals of theTextIconAlignment
class. Otherwise anIllegalArgumentException
exception will be thrown.- Parameters:
name
- the name of the alignment literal
-
getMnemonicResID
public String getMnemonicResID()
Returns the resource ID for the mnemonic.- Returns:
- the mnemonic's resource ID
-
setMnemonicResID
public void setMnemonicResID(String mnemonicResID)
Sets the resource ID for the mnemonic. (As group the group set by
will be used.)TextData.setResgrp(String)
- Parameters:
mnemonicResID
- the resource ID of the mnemonic
-
getMnemonicKey
public String getMnemonicKey()
Returns the key code of the mnemonic.- Returns:
- the mnemonic's key code
-
setMnemonicKey
public void setMnemonicKey(String mnemonicKey)
Sets the mnemonic's key code.- Parameters:
mnemonicKey
- the key code
-
getMnemonic
public char getMnemonic()
Returns the mnemonic character. If the mnemonic is defined through a resource, this resource is now resolved. If the mnemonic is a string with more than a single character, only the first character is returned.- Returns:
- the mnemonic (0 for undefined)
-
-