|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent com.jidesoft.combobox.AbstractComboBox com.jidesoft.combobox.TreeComboBox
public class TreeComboBox
TreeComboBox
is just like a normal JComboBox which you can choose a value from a drop-down tree.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected Object |
_object
|
protected TreeModel |
_treeModel
|
protected int |
maximumRowCount
This protected field is implementation specific. |
protected TreeCellRenderer |
renderer
This protected field is implementation specific. |
static String |
TREE_MODEL_PROPERTY
|
Fields inherited from class com.jidesoft.combobox.AbstractComboBox |
---|
_dialog, _editable, _editor, _listDataListener, _oldSelectedItemReminder, _popupButton, _popupPanel, _renderer, actionCommand, CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED, CLIENT_PROPERTY_TABLE_CELL_EDITOR, CLIENT_PROPERTY_TABLE_CELL_RENDERER, COMMIT, COMMIT_OR_RESET, COMMIT_OR_REVERT, dataModel, DIALOG, DROPDOWN, HIDE_POPUP_KEY, PERSIST, PROPERTY_SELECTED_ITEM, RESET, REVERT, selectedItemReminder |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
TreeComboBox()
|
|
TreeComboBox(Hashtable<?,?> objects)
Creates a new TreeComboBox . |
|
TreeComboBox(Object[] objects)
Creates a new TreeComboBox . |
|
TreeComboBox(TreeModel model)
Creates a new TreeComboBox . |
|
TreeComboBox(TreeNode root)
Creates a new TreeComboBox . |
|
TreeComboBox(TreeNode root,
boolean asksAllowsChildren)
Creates a new TreeComboBox . |
|
TreeComboBox(Vector<?> objects)
Creates a new TreeComboBox . |
Method Summary | |
---|---|
protected String |
convertElementToString(Object object)
Converts the element from object to string so that i can display in the text field of TreeComboBox. |
AbstractComboBox.EditorComponent |
createEditorComponent()
Subclass should implement this method to create the actual editor component. |
PopupPanel |
createPopupComponent()
Subclass should implement this method to create the actual popup component. |
protected JTree |
createTree(TreeModel model)
Creates the tree. |
protected TreeChooserPanel |
createTreeChooserPanel(TreeModel model)
Creates the TreeChooserPanel. |
TreeCellRenderer |
getCellRenderer()
Returns the renderer used to display the selected item in the JComboBox field. |
protected JComponent |
getDelegateTarget()
|
int |
getMaximumRowCount()
Returns the maximum number of items the combo box can display without a scrollbar. |
JTree |
getTree()
Gets the underlying JTree. |
TreeModel |
getTreeModel()
Gets the tree model that will be used by the tree in the popup. |
protected void |
initComponent(ComboBoxModel model)
Initialize this component such as creating button, editor etc. |
boolean |
isDoubleClickExpand()
Get the flag indicating if the mouse double click would expand the tree path instead of just select it. |
protected boolean |
isValidSelection(TreePath path)
Checks if a given tree path is a valid selection for combobox. |
protected List<TreePath> |
populateTreePaths(JTree tree)
|
void |
setCellRenderer(TreeCellRenderer aRenderer)
Sets the renderer that paints the list items and the item selected from the list in the JComboBox field. |
void |
setDoubleClickExpand(boolean doubleClickExpand)
Set the flag indicating if the mouse double click would expand the tree path instead of just select it. |
void |
setMaximumRowCount(int count)
Sets the maximum number of rows the JComboBox displays. |
void |
setTreeModel(TreeModel treeModel)
Sets the tree model that will be used by the tree in the popup. |
protected void |
setupTree(JTree tree)
Setups the JTree for the tree used in the popup panel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected TreeCellRenderer renderer
getCellRenderer()
,
setCellRenderer(javax.swing.tree.TreeCellRenderer)
protected int maximumRowCount
getMaximumRowCount()
,
setMaximumRowCount(int)
protected Object _object
protected TreeModel _treeModel
public static final String TREE_MODEL_PROPERTY
Constructor Detail |
---|
public TreeComboBox()
public TreeComboBox(Object[] objects)
TreeComboBox
.
objects
- the objectspublic TreeComboBox(Vector<?> objects)
TreeComboBox
.
objects
- the objectspublic TreeComboBox(Hashtable<?,?> objects)
TreeComboBox
.
objects
- the objectspublic TreeComboBox(TreeNode root)
TreeComboBox
.
root
- the root nodepublic TreeComboBox(TreeNode root, boolean asksAllowsChildren)
TreeComboBox
.
root
- the root nodeasksAllowsChildren
- the flag indicating if allows childrenpublic TreeComboBox(TreeModel model)
TreeComboBox
.
model
- the tree modelMethod Detail |
---|
protected void initComponent(ComboBoxModel model)
AbstractComboBox
initComponent
in class AbstractComboBox
model
- ComboBoxModel if any. If it's null, use InfiniteComboBoxModel.protected List<TreePath> populateTreePaths(JTree tree)
public AbstractComboBox.EditorComponent createEditorComponent()
AbstractComboBox
createEditorComponent
in class AbstractComboBox
public PopupPanel createPopupComponent()
AbstractComboBox
createPopupComponent
in class AbstractComboBox
protected TreeChooserPanel createTreeChooserPanel(TreeModel model)
TreeChooserPanel panel = new TreeChooserPanel(object) {
protected void setupTree(final JTree tree) {
super.setupTree(tree);
tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
if (e.getPath() != null && !Boolean.TRUE.equals(tree.getClientProperty(PopupPanel.SELECTED_BY_MOUSE_ROLLOVER)))
{
if (isValidSelection(e.getPath())) {
setSelectedObject(item, false);
getEditor().setItem(e.getPath());
getEditor().selectAll();
}
}
}
});
TreeComboBox.this.setupTree(tree);
}
protected boolean isValidSelection(TreePath path) {
return TreeComboBox.this.isValidSelection(path);
}
};
model
- the tree model
protected JTree createTree(TreeModel model)
model
- the tree model.
protected void setupTree(JTree tree)
tree
- the JTree instancepublic void setMaximumRowCount(int count)
JComboBox
displays. If the number of objects in the model is
greater than count, the combo box uses a scrollbar.
count
- an integer specifying the maximum number of items to display in the list before using a scrollbar
description: The maximum number of rows the popup should havepublic int getMaximumRowCount()
public void setCellRenderer(TreeCellRenderer aRenderer)
aRenderer.getListCellRendererComponent
is called, passing the list
object and an index of -1.
aRenderer
- the ListCellRenderer
that displays the selected item expert: true description: The
renderer that paints the item selected in the list.AbstractComboBox.setEditor(javax.swing.ComboBoxEditor)
public TreeCellRenderer getCellRenderer()
JComboBox
field.
ListCellRenderer
that displays the selected item.public JTree getTree()
createTreeChooserPanel(javax.swing.tree.TreeModel)
method and create your own TreeChooserPanel and JTree.
If you want to programmatically set selected row on the JTree, you can use this method. However do not keep the
returned value and use it later because combobox may create a new JTree if the popup is volatile.
Please note, this method will show the popup automatically if the combobox itself is showing (isShowing returns
true). Otherwise, it could return null if the popup was never shown before.
protected JComponent getDelegateTarget()
getDelegateTarget
in class AbstractComboBox
protected String convertElementToString(Object object)
object
- the object
protected boolean isValidSelection(TreePath path)
path
- the tree path
public TreeModel getTreeModel()
public void setTreeModel(TreeModel treeModel)
treeModel
- the tree modelpublic boolean isDoubleClickExpand()
public void setDoubleClickExpand(boolean doubleClickExpand)
doubleClickExpand
- the flagisDoubleClickExpand()
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |