borland Packages Class Hierarchy dbswing Package
java.lang.Object +----java.awt.Component +----java.awt.Container +----javax.swing.JComponent +----javax.swing.AbstractButton +----javax.swing.JToggleButton +----com.borland.dbswing.JdbToggleButton
Variables Constructors Properties Methods Event Listeners
Implements DBDataBinder, ColumnAware, DataSetAware, ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants
The JdbToggleButton
component extends the javax.swing.JToggleButton
class. It adds the following properties:
dataSet
- identifies the DataSet
to which the selectedDataValue
or unselectedDataValue
is assigned.
columnName
- the name of the column of the DataSet
to which the value is assigned.
selectedDataValue
- the value to assign to the column specified by columnName
of the specified DataSet
when the button is selected.
unselectedDataValue
- the value to assign to the column specified by columnName
of the specified DataSet
when the button is not selected.
unknownDataValueMode
- specifies the policy for synchronizing the button state when an unknown DataSet
is encountered.
textWithMnemonic
- makes the letter that appears in the text string after an ampersand (&) a mnemonic character or hot key.
JdbToggleButton
sets its text
, alignment
, background
, foreground
, and font
properties using the property settings from the Column
specified with the columnName
property, if they are defined, unless these properties are set explicitly on the JdbToggleButton
itself. The value of the text
property is considered to be its default state (not explicitly set) if text
is null
or an empty string ("").
Like JTogglebutton
, JdbToggleButton
has constructors that set an initial value. This is seldom useful for a data-aware control. To set a JdbToggleButton
to a default value for each new row of a DataSet
, set the default property of the Column
the toggle button is bound to.
selectedDataValue
and unselectedDataValue
propertiesIn the Inspector, at design-time, the selectedDataValue
and unselectedDataValue
property values are set as String
s, regardless of the data type of the column. JBuilder converts the value to the proper data type if needed.
At runtime, these properties take on default values if they are not set. This is most useful when the component is bound to
a boolean column; then selectedDataValue
defaults to true
and unselectedDataValue
defaults to false
. When bound to a numeric column, the defaults are 1 and 0; when bound to a String
column, the defaults are true
and false
.
The values of the selectedDataValue
and unselectedDataValue
properties must be consistent with the display mask of the bound-to column. This usually isn't
an issue because this component is seldom bound to real number or date/time
columns, which are the ones that benefit most from custom formatting. However,
if you do specify a display mask for a column bound to one of these components,
it's important to be aware of this rule.
For example, a boolean column with a
display mask of "Yes;No" bound to a JdbToggleButton
with a selectedDataValue
of
true
will fail on open with a com.borland.dx.text.InvalidFormatException
with the message "Error in parsing string". Set its selectedDataValue
to"Yes"
instead.
For more information about these properties, see selectedDataValue
and unselectedDataValue
properties in DBButtonDataBinder
.
protected DBButtonDataBinder dataBinderThe
DBButtonDataBinder
that makes JdbToggleButton
data-aware.
public JdbToggleButton()Constructs a
JdbToggleButton
component by calling the constructor of this
class that takes a String
, an Icon
, and a boolean
. Passes default values of null
, null
, and false
to that constructor. The button has no text or icon and is initially unselected.
public JdbToggleButton(String text)Constructs a
JdbToggleButton
component by calling the constructor of this
class that takes a String
, an Icon
, and a boolean
. Passes the specified text string, along with default values of null
and false
to that constructor.
text
public JdbToggleButton(String text, boolean selected)Constructs a
JdbToggleButton
component by calling the constructor of this
class that takes a String
, an Icon
, and a boolean
as parameters. Passes the specified text string and boolean
value, along with a default value of null
for the Icon
, to that constructor.
text
selected
true
, the button is initially selected. If false
, the button is not initially selected.
public JdbToggleButton(String text, Icon icon)Constructs a
JdbToggleButton
component by calling the constructor of this
class that takes a String
, an Icon
, and a boolean
as parameters. Passes the specified text string and icon, along with a default boolean
value of false
, to that constructor.
text
icon
public JdbToggleButton(String text, Icon icon, boolean selected)Constructs a
JdbToggleButton
component by calling the constructor of its superclass and passing the specified String
, Icon
, and boolean
value. This constructor is called by all of JdbToggleButton
's other constructors, and is the only one of them which calls a constructor of its superclass directly.
text
icon
selected
true
, the button is initially selected. If false
, the button is not initially selected.
public JdbToggleButton(Icon icon)Constructs a
JdbToggleButton
component by calling the constructor of this
class which takes a String
, an Icon
, and a boolean
value as parameters. Passes the specified icon, along with default values of null
for the String
, and false
for the boolean
, to that constructor.
icon
public JdbToggleButton(Icon icon, boolean selected)Constructs a
JdbToggleButton
component by calling the constructor of this
class that takes a String
, an Icon
, and a boolean
as parameters. Passes the specified icon and boolean
value, along with a null
String
, to that constructor.
icon
selected
true
, the button is initially selected. If false
, the button is not initially selected.
public String getColumnName() public void setColumnName(String columnName)Specifies a column name in the
DataSet
to display data from and write data to. Usually the data type for the value in the column linked to a ToggleButton
is boolean. Regardless of the type, the selectedDataValue
and unselectedDataValue
values are specified as String
s and JBuilder converts them to the appropriate data type.
selectedDataValue
, unselectedDataValue
public DataSet getDataSet() public void setDataSet(DataSet dataSet)Specifies the
DataSet
object that is the source of the data to display and to write to.
public String getSelectedDataValue() public void setSelectedDataValue(String selectedValue)Returns and sets the value to be written to the
DataSet
when the button is selected. Setting this value to null
results in nothing being written to the DataSet
. Setting this value to an empty string ("") results in the DataSet
value being cleared.
Note that regardless of the data type of the column, the property value is set as a String
. JBuilder converts it to the proper data type if needed.
public String getTextWithMnemonic() public void setTextWithMnemonic(String text)
textWithMnemonic
is a convenience property for setting the toggle button's text, which interprets an ampersand character (&) within the text as an instruction to make the character following the ampersand the mnemonic character for the button. To put an ampersand in the text but not make the character following it a hot key, put a backslash before the ampersand. To make a literal ampersand the hot key, put two consecutive ampersands in the text.
When the String
entered is displayed in the Inspector and as the toggle button's text in design mode and at runtime, the ampersand is removed and the hot key character is underlined.
This property can be used instead of the usual text
property, even if a mnemonic character is not embedded in the text. It is particularly useful for applications that resource strings for internationalization, because the text and mnemonic can be specified in a single String
.
Note that the first occurrence of the mnemonic character is always denoted visibly as the mnemonic key, despite the location of the ampersand within the text. Furthermore, only the first occurrence of an ampersand is removed from the text.
When textWithMnemonic
is set, both the text
and textWithMnemonic
properties are updated. If both the text
and textWithMnemonic
properties are set, the most recently set property takes precedence.
textWithMnemonic
is a bound property, and therefore a property change event is fired when its value is modified.
public int getUnknownDataValueMode() public void setUnknownDataValueMode(int mode)Returns and sets the policy for setting the button state when synchronizing a button with its
DataSet
value when the value doesn't match either of the selectedDataValue
or unselectedDataValue
property values. These are the values used for the mode parameter:
DataSet
is cleared.
DBButtonDataBinder
public String getUnselectedDataValue() public void setUnselectedDataValue(String unselectedValue)Returns and sets the value written to the
DataSet
when the button is unselected. If you set this value to null
, nothing is written to the DataSet
. If you set this value to an empty string (""), the DataSet
value is cleared.
Note that regardless of the data type of the column, the property value is set as a String
. JBuilder converts it to the proper data type if needed.
public void addActionListener(java.awt.event.ActionListener ) public void removeActionListener(java.awt.event.ActionListener )
public void addAncestorListener(javax.swing.event.AncestorListener ) public void removeAncestorListener(javax.swing.event.AncestorListener )
public void addChangeListener(javax.swing.event.ChangeListener ) public void removeChangeListener(javax.swing.event.ChangeListener )
public synchronized void addComponentListener(java.awt.event.ComponentListener ) public synchronized void removeComponentListener(java.awt.event.ComponentListener )
public synchronized void addContainerListener(java.awt.event.ContainerListener ) public synchronized void removeContainerListener(java.awt.event.ContainerListener )
public synchronized void addFocusListener(java.awt.event.FocusListener ) public synchronized void removeFocusListener(java.awt.event.FocusListener )
public synchronized void addInputMethodListener(java.awt.event.InputMethodListener ) public synchronized void removeInputMethodListener(java.awt.event.InputMethodListener )
public void addItemListener(java.awt.event.ItemListener ) public void removeItemListener(java.awt.event.ItemListener )
public synchronized void addKeyListener(java.awt.event.KeyListener ) public synchronized void removeKeyListener(java.awt.event.KeyListener )
public synchronized void addMouseListener(java.awt.event.MouseListener ) public synchronized void removeMouseListener(java.awt.event.MouseListener )
public synchronized void addMouseMotionListener(java.awt.event.MouseMotionListener ) public synchronized void removeMouseMotionListener(java.awt.event.MouseMotionListener )
public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener ) public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener )
public synchronized void addVetoableChangeListener(java.beans.VetoableChangeListener ) public synchronized void removeVetoableChangeListener(java.beans.VetoableChangeListener )