|
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.swing.LabeledTextField
public class LabeledTextField
LabeledTextField
is a combo component which includes text field and an optional JLabel in the front and
another optional AbstractButton at the end.
Nested Class Summary | |
---|---|
static interface |
LabeledTextField.PopupMenuCustomizer
The PopupMenuCustomizer for the context menu when clicking on the label/icon before the text field. |
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 AbstractButton |
_button
|
protected KeyStroke |
_contextMenuKeyStroke
|
protected LabeledTextField.PopupMenuCustomizer |
_customizer
|
protected JLabel |
_hintLabel
|
protected String |
_hintText
|
protected Icon |
_icon
|
protected JLabel |
_label
|
protected String |
_labelText
|
protected boolean |
_showHintTextWhenFocused
|
protected JTextField |
_textField
|
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 | |
---|---|
LabeledTextField()
|
|
LabeledTextField(Icon icon)
|
|
LabeledTextField(Icon icon,
String labelText)
|
Method Summary | |
---|---|
protected Point |
calculateContextMenuLocation()
Calculates the locatioin of the context menu. |
protected AbstractButton |
createButton()
Creates the button that appears after the text field. |
protected JidePopupMenu |
createContextMenu()
Creates a context menu. |
protected JLabel |
createLabel()
Creates the label that appears before the text field. |
protected JTextField |
createTextField()
Creates a text field. |
protected void |
customizePopupMenu(JPopupMenu menu)
Customizes the popup menu. |
int |
getBaseline(int width,
int height)
|
AbstractButton |
getButton()
Gets the AbstractButton that appears after text field. |
KeyStroke |
getContextMenuKeyStroke()
Gets the keystroke that will bring up the context menu. |
String |
getHintText()
Gets the hint text when the field is empty and not focused. |
Icon |
getIcon()
Gets the icon that appears before the text field. |
JLabel |
getLabel()
Gets the JLabel that appears before text field. |
String |
getLabelText()
Gets the text that appears before the text field. |
LabeledTextField.PopupMenuCustomizer |
getPopupMenuCustomizer()
Gets the PopupMenuCustomizer. |
String |
getText()
Gets the text in this TextField. |
JTextField |
getTextField()
Gets the actual text field. |
protected void |
initComponent()
|
protected void |
initLayout(JLabel label,
JTextField field,
AbstractButton button)
Setup the layout of the components. |
boolean |
isShowHintTextWhenFocused()
Checks if the hint text will still be shown when the text field has focus. |
void |
setColumns(int columns)
Sets the number of columns in this TextField, and then invalidate the layout. |
void |
setContextMenuKeyStroke(KeyStroke contextMenuKeyStroke)
Changes the keystroke that brings up the context menu which is normally shown when user clicks on the label icon before the text field. |
void |
setEnabled(boolean enabled)
|
void |
setHintText(String hintText)
Sets the hint text. |
void |
setIcon(Icon icon)
Sets the icon that appears before the text field. |
void |
setLabelText(String text)
Sets the text that appears before the text field. |
void |
setPopupMenuCustomizer(LabeledTextField.PopupMenuCustomizer customizer)
Sets the PopupMenuCustomizer. |
void |
setShowHintTextWhenFocused(boolean showHintTextWhenFocused)
Sets the flag if the hint text will still be shown when the text field has focus. |
void |
setText(String text)
Sets the text in this TextField. |
protected void |
showContextMenu()
Shows the context menu. |
void |
updateUI()
|
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected JTextField _textField
protected JLabel _label
protected AbstractButton _button
protected String _labelText
protected Icon _icon
protected String _hintText
protected boolean _showHintTextWhenFocused
protected JLabel _hintLabel
protected LabeledTextField.PopupMenuCustomizer _customizer
protected KeyStroke _contextMenuKeyStroke
Constructor Detail |
---|
public LabeledTextField()
public LabeledTextField(Icon icon)
public LabeledTextField(Icon icon, String labelText)
Method Detail |
---|
protected void initComponent()
protected void showContextMenu()
protected Point calculateContextMenuLocation()
protected void customizePopupMenu(JPopupMenu menu)
menu
- the menu to customizeprotected void initLayout(JLabel label, JTextField field, AbstractButton button)
label
- the labelfield
- the text field.button
- the buttonpublic boolean isShowHintTextWhenFocused()
public void setShowHintTextWhenFocused(boolean showHintTextWhenFocused)
showHintTextWhenFocused
- true or false.protected JTextField createTextField()
protected JidePopupMenu createContextMenu()
public void updateUI()
updateUI
in class JPanel
protected AbstractButton createButton()
protected JLabel createLabel()
public void setLabelText(String text)
text
- the text that appears before the text field.public String getLabelText()
public void setIcon(Icon icon)
icon
- the icon that appears before the text field.public Icon getIcon()
public JLabel getLabel()
public AbstractButton getButton()
public void setColumns(int columns)
columns
- the number of columns for this text field.public void setText(String text)
text
- the new text in this TextField.public String getText()
public JTextField getTextField()
public void setEnabled(boolean enabled)
setEnabled
in class JComponent
public int getBaseline(int width, int height)
getBaseline
in class JComponent
public String getHintText()
public void setHintText(String hintText)
hintText
- the new hint text.public LabeledTextField.PopupMenuCustomizer getPopupMenuCustomizer()
public void setPopupMenuCustomizer(LabeledTextField.PopupMenuCustomizer customizer)
LabeledTextField
.
PopupMenuCustomizer has a customize method. The popup menu of this menu will be passed in. You can
add/remove/change the menu items in customize method. For example,
field.setPopupMenuCustomzier(new LabeledTextField.PopupMenuCustomizer() {
void customize(LabledTextField field, JPopupMenu menu) {
menu.removeAll();
menu.add(new JMenuItem("..."));
menu.add(new JMenuItem("..."));
}
}
If the menu is never used, the two add methods will never be called thus improve the performance.
customizer
- the PopupMenuCustomizerpublic KeyStroke getContextMenuKeyStroke()
public void setContextMenuKeyStroke(KeyStroke contextMenuKeyStroke)
contextMenuKeyStroke
- the new keystroke to bring up the context menu.
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |