SilverStream
Application Server 3.5

com.sssw.rt.form
Class AgcChoice

java.lang.Object
 |
 +--java.awt.Component
       |
       +--java.awt.Choice
             |
             +--com.sssw.rt.atlas.AtChoice
                   |
                   +--com.sssw.rt.form.AgcChoice
All Implemented Interfaces:
AgiControl, AgiHelpInfo, AgiRowSetManager, ImageObserver, ItemSelectable, MenuContainer, Serializable

public class AgcChoice
extends com.sssw.rt.atlas.AtChoice
implements AgiRowSetManager, AgiControl

The AgcChoice control extends the standard drop-down list control supplied by the Java AWT (java.awt.Choice) by adding the ability to bind the control to a data source. It displays a list of values to users. The users can browse the list of values and select a value from the list.

When the control is bound to a database column via the Data Column property, the value in the database sets the initially selected item in the list. If the user makes a different selection, that value becomes the value associated with the current row. The selected value is saved to the database when you call updateRows() for the form.

In addition to being data-bound, the control is a data-loaded control in which a database table or other data source can provide the list of values. You can use methods of AgiRowSetManager to navigate the list. However, changes to the list items do not affect the underlying data; therefore, calling updateRows() is not allowed. If you call it for the control, updateRows() throws AgoUnsupportedOperationException.

Properties:
Automatic Query, Choices, Control Type, Data Column, Display Value, Distinct, Enabled, Font Name, Font Size, Font Style, Height, Help Page, Left, Limit Rows, Load Choices, Maximum Rows, Name, Order By, Storage Value, Table, Tool Tip, Top, Values, Visible, Where Clause, Width
Events:
focusGained, focusLost, itemStateChanged, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, validationFailed, validationTest, valueChanged
See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.sssw.rt.form.AgiControl
IMAGE_MODE_CENTERED, IMAGE_MODE_NORMAL, IMAGE_MODE_STRETCH, IMAGE_MODE_TILED
 
Constructor Summary
AgcChoice()
           
 
Method Summary
 void add(String title, Object value)
          Inserts an item at the end of the Choice, specifying both the display text and the list item's value (may be null).
 void addRow(String title)
          Deprecated. replaced by AgcChoice.add(String,Object).
 int countRows()
          Deprecated. replaced by Choice.getItemCount().
 Color getBackgroundColor()
          Deprecated. replaced by Component.getBackground().
 AgoFontIdentifier getFontIdentifier()
          Returns the SilverStream font object (AgoFontIdentifier) for the control's text.
 Object getItemValue(int index)
          Get the value for the item with the specified index.
 String getRowText(int index)
          Deprecated. replaced by Choice.getItem(int).
 Object getRowValue(int index)
          Deprecated. replaced by AgcChoice.getItemValue(int).
 Object getValue()
          Returns the control's value.
 void insert(String title, Object value, int index)
          Inserts an item at the specified index in the Choice, specifying both the display text and the list item's value (may be null).
 void removeAllRows()
          Deprecated. replaced by Choice.removeAll().
 void removeRow(int index)
          Deprecated. replaced by Choice.remove(int).
 void setBackgroundColor(Color backgroundcolor)
          Deprecated. replaced by Component.setBackground(Color).
 void setFontIdentifier(AgoFontIdentifier fontidentifier)
          Assigns the SilverStream font object (AgoFontIdentifier) to the control's text.
 void setValue(Object value)
          Selects the row whose value is equal to the specified value.
 
Methods inherited from class com.sssw.rt.atlas.AtChoice
addNotify, deliverMouseEvent, deliverMouseMoveEvent, doAtCommand, enableAtCommands, getChoiceHeight, getHelper, getToolTipText, getToolTipText, grabFocus, isFocusTraversable, isRequestFocusEnabled, preprocessKeyEvent, processEvent, requestFocus, setRequestFocusEnabled, setToolTipText
 
Methods inherited from class java.awt.Choice
add, addItem, addItemListener, countItems, getItem, getItemCount, getSelectedIndex, getSelectedItem, getSelectedObjects, insert, paramString, processItemEvent, remove, remove, removeAll, removeItemListener, select, select
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods implemented from interface com.sssw.rt.form.AgiControl
getBackgroundImage, getBackgroundImageMode, getComponent, getHelpInfo, setBackgroundImage, setBackgroundImageMode, setHelpInfo
 
Methods implemented from interface com.sssw.rt.util.AgiRowSetManager
clearRows, haveRowsChanged, query, query, refreshRows, updateRows
 

Constructor Detail

AgcChoice

public AgcChoice()
Method Detail

getFontIdentifier

public AgoFontIdentifier getFontIdentifier()
Returns the SilverStream font object (AgoFontIdentifier) for the control's text.
Usage:

The AgoFontIdentifier object consists of three parts: a Font Name, a Font Style and a Font Size. The Font Name can be one of these values: Dialog, SansSerif, Serif, Monospaced, Helvetica, TimesRoman, Courier, DialogInput, Zapfdingbats. At runtime, Java translates this value to the appropriate font installed on the system.

The Font Style can be one of these values:

  • AgoFontIdentifier.PLAIN
  • AgoFontIdentifier.BOLD
  • AgoFontIdentifier.ITALIC
  • AgoFontIdentifier.BOLD + AgoFontIdentifier.ITALIC

The Font Size can be any integer.

Example:

The following code fragment illustrates how to construct a new AgoFontIdentifier object (called newFont) and how to call the getFontIdentifier() method:

  AgoFontIdentifier font;
  font = ControlName1.getFontIdentifier();
 
See Also:
AgcChoice.setFontIdentifier(AgoFontIdentifier)

setFontIdentifier

public void setFontIdentifier(AgoFontIdentifier fontidentifier)
Assigns the SilverStream font object (AgoFontIdentifier) to the control's text.
Parameters:
fontidentifier - specifies the AgoFontIdentifier object that assigns the font for the control.
Usage:

The AgoFontIdentifier object consists of three parts: a Font Name, a Font Style and a Font Size. The Font Name can be one of these values: Dialog, SansSerif, Serif, Monospaced, Helvetica, TimesRoman, Courier, DialogInput, Zapfdingbats. At runtime, Java translates this value to the appropriate font installed on the system.

The Font Style can be one of these values:

  • AgoFontIdentifier.PLAIN
  • AgoFontIdentifier.BOLD
  • AgoFontIdentifier.ITALIC
  • AgoFontIdentifier.BOLD + AgoFontIdentifier.ITALIC

The Font Size can be any integer.

Example:

This code fragment illustrates how to construct a new AgoFontIdentifier object (called newFont) and how to call the setFontIdentifier() method:

  AgoFontIdentifier     newFont;
  String		           newName;
  int	               newSize;
  int		           newStyle;
 
  newName="TimesRoman";
  newSize=20;
  newStyle=AgoFontIdentifier.ITALIC;
  newFont=new AgoFontIdentifier(newName, newStyle, newSize);
 
  ControlName1.setFontIdentifier(newFont);
 
See Also:
AgcChoice.getFontIdentifier()

getBackgroundColor

public Color getBackgroundColor()
Deprecated. replaced by Component.getBackground().

Gets the control's background color.

setBackgroundColor

public void setBackgroundColor(Color backgroundcolor)
Deprecated. replaced by Component.setBackground(Color).

Sets the control's background color.
Parameters:
backgroundcolor -  

addRow

public void addRow(String title)
Deprecated. replaced by AgcChoice.add(String,Object).

Adds a row to the end of the current list.
Parameters:
text - specifies the text of the row to add.
Usage:

The addRow() method adds a row dynamically at runtime. Rows added dynamically are not saved across sessions or instances of the control in the way that rows added as properties of the control are.

See Also:
AgcChoice.removeRow(int), AgcChoice.removeAllRows()

add

public void add(String title,
                Object value)
Inserts an item at the end of the Choice, specifying both the display text and the list item's value (may be null).
Parameters:
title - the text to be displayed to represent the value in the Choice list.
value - the value of the new item.
Usage:

You may need to call the awt method validate() after calling add() in order to make the controls redraw correctly. Specifically, if you programmatically add a subform containing a tab control on which there are other controls, say, buttons. The tab control shows up but the buttons don't until you call validate() - or resize the designer, which has the same effect.

Example:
  ControlName1.add("One", new Integer(1));
  ControlName1.add("Two", new Integer(2));
 
See Also:
AgcChoice.removeRow(int), AgcChoice.removeAllRows()

insert

public void insert(String title,
                   Object value,
                   int index)
Inserts an item at the specified index in the Choice, specifying both the display text and the list item's value (may be null).
Parameters:
title -  
value -  
index -  
Usage:

If index is -1, the item is added as the last item.

Example:
 

removeRow

public void removeRow(int index)
Deprecated. replaced by Choice.remove(int).

Removes the specified row from the control.
Parameters:
index - specifies the index of the row to remove.
Usage:

The rows are zero-based.

Example:

The following code fragment illustrates how to remove the row whose index is three.

  ControlName1.removeRow(3);
 
See Also:
AgcChoice.addRow(String)

removeAllRows

public void removeAllRows()
Deprecated. replaced by Choice.removeAll().

Removes all rows from the control.
Example:

The following code fragment illustrates how to use the removeAllRows() method.

  ControlName1.removeAllRows();
 
See Also:
AgcChoice.addRow(String), AgcChoice.removeRow(int)

countRows

public int countRows()
Deprecated. replaced by Choice.getItemCount().

Returns the number of rows.
Usage:

The rows are zero-based.


getRowText

public String getRowText(int index)
Deprecated. replaced by Choice.getItem(int).

Returns the text of the specified row.
Parameters:
index - specifies the index of the row containing the text to be obtained.
Usage:

The rows are zero-based.


getRowValue

public Object getRowValue(int index)
Deprecated. replaced by AgcChoice.getItemValue(int).

Returns the value of the specified row.
Parameters:
index - specifies the index of the row whose value is to be obtained.
Usage:

The value of a row is specified in the value parameter when adding a new row. If this value is null, then this method returns the text of the row as a String.

The rows are zero-based.


getItemValue

public Object getItemValue(int index)
Get the value for the item with the specified index.
Parameters:
index - the item's index.
Usage:

The value of a row is specified in the value parameter when adding a new row. If this value is null, then this method returns the text of the row as a String.

The rows are zero-based.

Example:
  Object value;
  value = ControlName1.getItemValue(3);
 

getValue

public Object getValue()
Returns the control's value. This is the internal value associated with the selected node.
Usage:

If the internal value is null, then the selected node's text is returned as a String. If no node is selected, then null is returned.

Example:
  Object value;
  value = ControlName1.getValue();
 
See Also:
AgcChoice.setValue(Object)

setValue

public void setValue(Object value)
Selects the row whose value is equal to the specified value.
Parameters:
value - specifies an internal value that specifies which row to select.
Usage:

At design time the contents of the internal value can be specified using the Property Inspector. It can be static or retrieved from the database. Each row can have its own internal value.

If the control is populated from a static list of data (that is the Load Choices property is set to Statically), the internal values can be specified using the Values property.

If the control is populated from the database (that is the Load Choices property is set to From Table), the internal values can be specified using the Storage value property.

Example:

Suppose a control is loaded statically:

  • The displayed text values are: Apple, Banana, Orange
  • The internal values are: 1, 2, 3

The following code fragment illustrates how to make Orange the selected item using setValue().

  int x=3;
  ControlName1.setValue(new Integer(x));
 

Note that this example uses the Integer class instead of the int primitive data type because an Object can not be cast to an int.

See Also:
AgcChoice.getValue()

SilverStream
Application Server 3.5