jbcl.view Package
java.lang.Object +----java.awt.Component +----java.awt.Container +----javax.swing.JComponent +----javax.swing.JScrollPane +----com.borland.jbcl.view.ListView +----com.borland.jbcl.control.ListControl
Variables Constructors Properties Methods Event Listeners
Implements VectorView, ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants
The ListView
component provides much of the behavior
and attributes of a list control. The ListControl
component
extends ListView
. It requires a
VectorModel
data model and a
VectorViewManager
view manager.
The itemHeight
property specifies the height of each
item in the list view while the itemWidth
property
specifies the width of each item. These properties work in
conjunction with the uniformHeight
and uniformWidth
properties. For example, setting itemHeight
to a value
sets uniformHeight
to true, meaning
that each item has the height specified in itemHeight
.
If no itemHeight
is specified and uniformHeight
is true, the height for each item is calculated
to be height of the first item in the list. If uniformHeight
is false, each item can have a different height.
To specify the margins around each item in the list, set the itemMargins
property.
To align the items in the view, set the alignment
property. The value of topIndex
determines which item
appears at the top of the list. You can determine if scrolling
within the view is smooth and continuous or scrolling
"snaps" to each item in the list view with the snapOrigin
property. The value of showFocus
determines whether the
item that has the subfocus in the list has a focus rectangle
around it. Setting showRollover
to true
means that the item that has the mouse cursor over it is
highlighted.
The value of subfocus
identifies the item that has
the current subfocus in the list. selection
provides
access to the set of selected items in the list view.
The readOnly
property determines whether the items in
the list can be edited. The startEdit()
begins an edit
session on an item and endEdit()
and endSafeEdit()
methods
end an edit session. When an edit session is underway, the editing
property is true. The value of editInPlace
enables or disables the editing of an items in the list. When the
autoEdit
property is true, the user can
begin editing an item by typing; otherwise, the user must press
F2 or Ctrl+Enter to begin an edit session.
Several properties and methods control how painting takes
place within the view. If directDraw
is true,
drawing bypasses the AWT paint queue and occurs directly. Setting
doubleBuffer
to true reduces flickering
during painting. To make mass changes to the list without waiting
for repainting after each change, use the batchMode
property. The getItemRectangle()
method retrieves the
rectangle that surrounds the item to be repainted. The repaintItem()
method paints a specified item and the repaintItems()
method paints all the items in the list.
For an example that uses ListView
, see the project file
ListView.jpr located in the
samples directory of your JBuilder installation.
public ListView()
Constructs a ListView
component with default property
values.
public int getAlignment() public void setAlignment(int alignment)Specifies the alignment (right, left, center) of the items in the list. Accepted values for the
align
argument are
listed in com.borland.dx.text.Alignment
where they are defined.
public boolean isAlwaysEdit() public void setAlwaysEdit(boolean autoEdit)This property has been deprecated. Use
autoEdit
.
public boolean isAutoAppend() public void setAutoAppend(boolean autoAppend)Enables or disables automatic item appending at the end of the list. By default, this property is false, and a user must insert rows with the Insert key or by navigating to the end of the list and pressing Ctrl+Down. Setting this property to true allows the user to append new items by navigating past the last item.
public boolean isAutoEdit() public void setAutoEdit(boolean autoEdit)Enables or disables automatic item editing in the list. By default, this property is true, and a user can edit values in any item on the list by typing a character on the keyboard. If set to false, the user must press F2 or Ctrl+Enter, or double-click to start an edit session. By default, this property is true.
public void setBackground(Color color)Determines the background color of the list view. Specify a
java.awt.Color
object for the color.
public boolean isBatchMode() public void setBatchMode(boolean batchMode)Enables or disables all painting in the list. This is used for programmatic mass updates to the list's model, selection, or other related objects, without triggering repaint messages. If true, painting is disabled; if false, painting occurs with each change to the list.
public Component getCoreComponent()Returns the contained
ListCore
(non-public) class instance as a Component
.
public boolean isDataToolTip() public void setDataToolTip(boolean dataToolTip)The
dataToolTip
property enables/disables the automatic tooltip mechanism to display the contents of the model (as text) in a tooltip window when the mouse is floating over the field. By default, this property is false. If dataToolTip
is set to true, the text stored in the toolTipText
property is discarded.
public boolean isDirectDraw() public void setDirectDraw(boolean direct)This property has been deprecated. Use
java.swing.JComponent#paintImmediately
.
public boolean isDoubleBuffer() public void setDoubleBuffer(boolean buffer)This property has been deprecated. Use
isDoubleBuffered
and setDoubleBuffered
.
public boolean isDragSubfocus() public void setDragSubfocus(boolean dragSubfocus)Enables or disables dragging of the subfocus item when dragging the mouse pointer over the list (with the mouse button pressed). By default, this property is true.
public boolean isEditing()A read-only property that returns true if an item is currently being edited in the list.
public boolean isEditInPlace() public void setEditInPlace(boolean editInPlace)Enables or disables item editing in the list. By default, this property is true, and a user can edit values in any item on the list. If set to false, the vector data cannot by modified by the user - except through programmatic access to the list's model.
public ItemEditor getEditor()Returns the item editor being used or null if the list is not being edited.
public void setEnabled(boolean enabled)Determines whether the view is enabled or disabled. If true, the control is enabled; if false, it isn't. When disabled, the view appears dimmed and cannot receive focus.
public void setFont(Font font)Sets the
java.awt.Font
to use in the list view.
public void setForeground(Color color)Sets the foreground in the list view to the specified
java.awt.Color
.
public boolean isGrowEditor() public void setGrowEditor(boolean growEditor)The
growEditor
property enables/disables the automatic sizing of an item's item editor. In some look and feel settings, the item editors must grow vertically to properly edit the data. By default, this property is set to true.
public int getItemHeight() public void setItemHeight(int newHeight)When set, the view need not scan through the entire list of items, examining the height of each, to determine which item has been clicked, selected, or edited. Instead, it calculates item vertical location based on the value of
itemHeight
.
Setting itemHeight
sets uniformHeight
to true. The height is expressed in pixels.
public Insets getItemMargins() public void setItemMargins(Insets margins)Specifies the space allowed between the actual edge of the item and the edge of its region allotted in the list. The
Insets
object that specifies the margins
around the items in the view.
public int getItemWidth() public void setItemWidth(int newWidth)When set, the view need not scan through the entire list of items, examining the width of each, to determine which item has been clicked, selected, or edited. Instead, it calculates item horizontal location based on the value of
itemWidth
.
Setting itemWidth
sets uniformWidth
to true. The width is expressed in pixels.
public Dimension getMinimumSize()Returns the minimum size of the list view.
public VectorModel getModel() public void setModel(VectorModel vm)Defines the
VectorModel
that this
list is displaying data from. If the current model is an instance
of WritableVectorModel
, an external user can get access
to it using getWriteModel()
.
public boolean isOpaque() public void setOpaque(boolean opaque)Controls the grid's opacity. If a
texture
is set, the opaque
property is automatically
set to true, which is the default value.
public boolean isPostOnEndEdit() public void setPostOnEndEdit(boolean post)Specifies whether to write changes to the model immediately upon the end of an edit. If true, the item is posted immediately; if false, it isn't. By default,
postOnEndEdit
is
true.
public Dimension getPreferredSize()Specifies the size that you would prefer layout managers to use for this field.
public boolean isReadOnly() public void setReadOnly(boolean ro)Used when you want the model to be treated as a read-only model though it is actually a
WritableVectorModel
.
This is commonly used to allow users to browse, but not edit, normally writable vectors of data.
public Point getScrollPosition() public void setScrollPosition(Point p)This property has been deprecated. Use
getViewport
and
setViewport
.
public WritableVectorSelection getSelection() public void setSelection(WritableVectorSelection vs)Defines a
WritableVectorSelection
manager. This allows multiple vector viewers to share the same
selection pool, and for the list to handle selection in a
generic manner so that users can plug in their own
implemention of a selection manager to have custom selection behavior.
public boolean isShowFocus() public void setShowFocus(boolean focus)Specifies whether the component displays a dotted rectangle that indicates the subfocus location. If true, a focus rectangle is visible; if false, it isn't.
public boolean isShowRollover() public void setShowRollover(boolean showRollover)Enables or disables the repainting of the rollover item. The rollover item is the item that currently has the mouse cursor floating over it. If
showRollover
is true, the item the mouse cursor is over is
highlighted.
If an ItemPainter plugged into the list ignores the ROLLOVER
bit, this property will have no effect. By default, showRollover
is true.
public boolean isSnapOrigin() public void setSnapOrigin(boolean snapOrigin)Controls whether or not the list will automatically snap the scroll position to align the top item with the top edge of the list. If set to false, the list will not snap the scroll position, and it will scroll smoothly with changes to the subfocus item. By default, this property is true.
public int getSubfocus() public void setSubfocus(int index)Specifies the index position of the item that has subfocus within the component.
public Image getTexture() public void setTexture(Image texture)Defines the image that is tiled repeatedly, producing a background texture.
public String getToolTipText() public void setToolTipText(String text)Determines the text that appears in the tool tip window. Specify the text as the value of the
text
parameter.
public int getTopIndex() public void setTopIndex(int index)Represents which item index is at the top-most of the visible items in the list. Setting this property doesn't move the subfocus item within the list, but scrolls the list to the appropriate position.
public boolean isUniformHeight() public void setUniformHeight(boolean uniformHeight)Determines whether the items in the list share a single uniform height. Setting
uniformHeight
to true allows the view to calculate item
vertical location based on the value of itemHeight
(or
the height of the first item) rather than scanning throught the
entire list of items.
If uniformHeight
is true, and
itemHeight
is null
(has not been set), the view assumes that the all items have the
height of the first item in the list.
If this property is false, items in the list can differ in height.
public boolean isUniformWidth() public void setUniformWidth(boolean uniformWidth)Determines whether the items in the list share a single uniform width. Setting
uniformWidth
to true
allows the view to calculate item horizontal location based on
the value of itemWidth
(or the width of the first item)
rather than scanning throught the entire list of items.
If uniformWidth
is true, and
itemWidth
is null (has not
been set), the view assumes that the all items have the width of
the first item in the list.
If this property is false, items in the list can differ in width.
public VectorViewManager getViewManager() public void setViewManager(VectorViewManager vvm)The
viewManager
property defines the VectorViewManager
that manages the ItemPainters
and ItemEditors
for the
list view.
public Dimension getViewportSize()This property has been deprecated. Use
getViewport
.
public WritableVectorModel getWriteModel()Returns the model for this list view.
public void addNotify()
Overrides: java.awt.Container.addNotify()
public void checkParentWindow()
protected VectorModel createDefaultModel()Creates a
BasicVectorContainer
.
protected WritableVectorSelection createDefaultSelection()Creates a
SingleVectorSelection
.
protected VectorViewManager createDefaultViewManager()Creates a
BasicViewManager
.
public void endEdit()Ends the current edit session (if any). If the value has been modified, it will be posted if
postOnEndEdit
is set to true (the default). If postOnEndEdit
is
false, the edit session will be terminated without saving the changes to the item's value.
public void endEdit(boolean post)Ends the editing of an item, marking the item editor for garbage collection. Writes the change to the model if
post
is true.
public Rectangle getItemRect(int index)Returns the
Rectangle
(in pixels) that bounds the
item at the specified index. Coordinates are relative to the
entire scrollable region inside of the ListView
. Use
getViewport
and setViewport
to calculate relative point positions to external components.
Returns the bounding rectangle of the item.
Parameters:
index
public boolean hasFocus()Determines whether the list has the focus. If it returns true, the grid has the focus.
Overrides: com.sun.java.swing.JComponent.hasFocus()
public int hitTest(int y)Returns the index of the item at the Y coordinate specified. Coordinates are relative to the entire scrollable region inside of the
ListView
. Use
getViewport
and
and setViewport
to calculate relative point positions to external components.
Returns the hit index, or -1 if nothing was hit.
Parameters:
y
public void repaintItem(int index)Repaints the item at the passed index.
Parameters:
index
public void repaintItems()Repaints all items in the list.
public void requestFocus()
Overrides: com.sun.java.swing.JComponent.requestFocus()
public void safeEndEdit()Ends the current edit session (if any), catching any exceptions. If the value has been modified, it will be posted if
postOnEndEdit
is set to true (the default). If postOnEndEdit
is
false, the edit session will be terminated without saving the
changes to the item's value.
public void safeEndEdit(boolean post)Ends the current edit session (if any), catching any exceptions. If the value has been modified, it will be posted if
post
is set to true. If post
is false,
the edit session will be terminated without saving the changes to
the item's value.
Parameters:
post
public void setScrollPosition(int x, int y)This property has been deprecated. Use
setViewport
.
public void startEdit(int index)Starts an edit session at 'index'. If
editInPlace
is false
or if readOnly is true, this method is a no-op.
Parameters:
index
public void updateUI()Updates the user interface of the view in preparation for painting.
Overrides: com.sun.java.swing.JScrollPane.updateUI()
public void addActionListener(ActionListener l) public void removeActionListener(ActionListener l)
public void addAncestorListener(javax.swing.event.AncestorListener ) public void removeAncestorListener(javax.swing.event.AncestorListener )
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 void addCustomItemListener(CustomItemListener l) public void removeCustomItemListener(CustomItemListener l)
public void addFocusListener(FocusListener l) public void removeFocusListener(FocusListener l)
public synchronized void addInputMethodListener(java.awt.event.InputMethodListener ) public synchronized void removeInputMethodListener(java.awt.event.InputMethodListener )
public void addKeyListener(KeyListener l) public void removeKeyListener(KeyListener l)
public void addModelListener(VectorModelListener listener) public void removeModelListener(VectorModelListener listener)
public void addMouseListener(MouseListener l) public void removeMouseListener(MouseListener l)
public void addMouseMotionListener(MouseMotionListener l) public void removeMouseMotionListener(MouseMotionListener l)
public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener ) public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener )
public void addSelectionListener(VectorSelectionListener listener) public void removeSelectionListener(VectorSelectionListener listener)
public void addSubfocusListener(VectorSubfocusListener listener) public void removeSubfocusListener(VectorSubfocusListener listener)
public synchronized void addVetoableChangeListener(java.beans.VetoableChangeListener ) public synchronized void removeVetoableChangeListener(java.beans.VetoableChangeListener )