|
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 javax.swing.JPanel com.jidesoft.combobox.AbstractComboBox.EditorComponent
public abstract class AbstractComboBox.EditorComponent
The EditorComponent is the one that used as editor. If you want to create your own EditorComponent that can be used in AbstractComboBox, you should always extend this class. EditorComponent is actually a JPanel. So you create whatever component you want to use it as editor and add it using BorderLayout to this EditorComponent. For example, the code below creates a JTextField as editor and add it to the EditorComponent. You can put this code in the constructor.
It has nothing but a value. Subclass should implement stringToObject which can convert from the text to the actual value.
if (LookAndFeelFactory.isLnfInUse(LookAndFeelFactory.AQUA_LNF)) {
setLayout(new BorderLayout(0, 0));
}
else {
setLayout(new BorderLayout(2, 2));
setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
}
_textField = createTextField();
if (!LookAndFeelFactory.isLnfInUse(LookAndFeelFactory.AQUA_LNF)
|| AbstractComboBox.this.getClientProperty(CLIENT_PROPERTY_TABLE_CELL_EDITOR ||
AbstractComboBox.this.getClientProperty(CLIENT_PROPERTY_TABLE_CELL_RENDERER) instanceof TableCellRenderer)
instanceof CellEditor) {
_textField.setBorder(BorderFactory.createEmptyBorder());
}
add(_textField, BorderLayout.CENTER);
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
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 Class<?> |
_class
|
protected Object |
_value
|
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 | |
---|---|
AbstractComboBox.EditorComponent(Class<?> clazz)
Constructs an EditorComponent for a specified type. |
Method Summary | |
---|---|
protected String |
convertElementToString(Object value)
Converts the value to string so that it can display in text field. |
protected Object |
convertStringToElement(String text)
Converts string to a value. |
int |
getHorizontalAlignment()
Returns the horizontal alignment of the content. |
Object |
getItem()
Gets the item (aka value) from this editor component. |
Dimension |
getPreferredSize()
Gets the default preferred size {100, 18}. |
abstract String |
getText()
Gets the text. |
int |
getVerticalAlignment()
Returns the vertical alignment of the content. |
abstract boolean |
isEditable()
Gets the editable attribute. |
protected void |
registerKeys(JComponent component)
|
abstract void |
setEditable(boolean editable)
Sets the editable attribute. |
void |
setHorizontalAlignment(int alignment)
Sets the horizontal alignment of the content. |
void |
setItem(Object value)
Sets the item (aka value) of the editor component. |
abstract void |
setText(String text)
Sets the text. |
void |
setVerticalAlignment(int alignment)
Sets the vertical alignment of the content. |
protected void |
textChanged()
|
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface javax.swing.ComboBoxEditor |
---|
addActionListener, getEditorComponent, removeActionListener, selectAll |
Field Detail |
---|
protected Class<?> _class
protected Object _value
Constructor Detail |
---|
public AbstractComboBox.EditorComponent(Class<?> clazz)
clazz
- the typeMethod Detail |
---|
public abstract String getText()
public abstract void setText(String text)
text
- the textpublic abstract void setEditable(boolean editable)
editable
- true or false.public abstract boolean isEditable()
public Object getItem()
getItem
in interface ComboBoxEditor
protected String convertElementToString(Object value)
value
- the value to be converted to string
protected Object convertStringToElement(String text)
text
- the text to be converted to element
public void setItem(Object value)
setItem
in interface ComboBoxEditor
value
- the new valueprotected void textChanged()
protected void registerKeys(JComponent component)
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
public int getHorizontalAlignment()
AlignmentSupport
AbstractButton
's default is SwingConstants.CENTER
,
but subclasses such as JCheckBox
may use a different default.
getHorizontalAlignment
in interface AlignmentSupport
horizontalAlignment
property,
one of the following values:
SwingConstants.RIGHT
SwingConstants.LEFT
SwingConstants.CENTER
SwingConstants.LEADING
SwingConstants.TRAILING
public void setHorizontalAlignment(int alignment)
AlignmentSupport
AbstractButton
's default is SwingConstants.CENTER
,
but subclasses such as JCheckBox
may use a different default.
setHorizontalAlignment
in interface AlignmentSupport
alignment
- the alignment value, one of the following values:
SwingConstants.RIGHT
SwingConstants.LEFT
SwingConstants.CENTER
SwingConstants.LEADING
SwingConstants.TRAILING
public int getVerticalAlignment()
AlignmentSupport
getVerticalAlignment
in interface AlignmentSupport
verticalAlignment
property, one of the
following values:
SwingConstants.CENTER
(the default)
SwingConstants.TOP
SwingConstants.BOTTOM
public void setVerticalAlignment(int alignment)
AlignmentSupport
setVerticalAlignment
in interface AlignmentSupport
alignment
- one of the following values:
SwingConstants.CENTER
(the default)
SwingConstants.TOP
SwingConstants.BOTTOM
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |