本文整理匯總了Java中javax.swing.ComboBoxEditor.getEditorComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java ComboBoxEditor.getEditorComponent方法的具體用法?Java ComboBoxEditor.getEditorComponent怎麽用?Java ComboBoxEditor.getEditorComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.ComboBoxEditor
的用法示例。
在下文中一共展示了ComboBoxEditor.getEditorComponent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addKeyListener
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
/**
* Key Listener Interface
*
* @param listener
*/
@Override
public void addKeyListener(final KeyListener listener)
{
//
// Combo Box Lookup
{
final ComboBoxEditor m_comboEditor = m_combo.getEditor();
final Component m_comboEditorComponent = m_comboEditor.getEditorComponent();
m_comboEditorComponent.addKeyListener(listener);
}
//
// Text Field Lookup
{
m_text.addKeyListener(listener);
}
}
示例2: install
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
public static boolean install( JComboBox combo ) {
boolean res = false;
ComboBoxEditor comboEditor = combo.getEditor();
if( comboEditor.getEditorComponent() instanceof JTextComponent ) {
JTextComponent textEditor = ( JTextComponent ) comboEditor.getEditorComponent();
Document doc = textEditor.getDocument();
doc.addDocumentListener( new AutoCompleteListener( combo ) );
setIgnoreSelectionEvents( combo, false );
combo.setEditable( true );
res = true;
}
combo.putClientProperty( "nb.combo.autocomplete", res ); //NOI18N
return res;
}
示例3: AutoCompletionComboBoxEditor
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
public AutoCompletionComboBoxEditor(ComboBoxEditor editor) {
if ((editor.getEditorComponent() instanceof JTextField)) {
this.editor = editor;
editorComponent = (JTextField) editor.getEditorComponent();
editorComponent.getDocument().addDocumentListener(docListener);
editorComponent.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
setSelectedItem(editorComponent.getText());
actionPerformed(new ActionEvent(this, 0, "editingStoped"));
e.consume();
} else if (e.getKeyCode() == KeyEvent.VK_TAB) {
if (isPopupVisible()) {
hidePopup();
} else {
showPopup();
}
e.consume();
} else {
super.keyPressed(e);
}
}
});
} else {
throw new IllegalArgumentException("Only JTextField allowed as editor component");
}
}
示例4: setEditor
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
@Override
public void setEditor(ComboBoxEditor anEditor) {
// check if editor component has changed at all: Otherwise listener already registered
if (getEditor() == null || anEditor.getEditorComponent() != getEditor().getEditorComponent()) {
super.setEditor(new AutoCompletionComboBoxEditor(anEditor));
}
}
示例5: createInputPanel
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private JPanel createInputPanel()
{
JPanel outerPanel = new JPanel(new BorderLayout());
JPanel innerPanel = new JPanel(new BorderLayout());
m_comboBox = new JComboBox(getHistory().toArray());
StringBuilder prototype = new StringBuilder(70);
for (int i = 0; i < 40; ++i)
prototype.append('-');
m_comboBox.setPrototypeDisplayValue(prototype.toString());
m_comboBox.setEditable(true);
ComboBoxEditor editor = m_comboBox.getEditor();
m_comboBox.addActionListener(this);
m_textField = (JTextField)editor.getEditorComponent();
m_textField.selectAll();
KeyListener keyListener = new KeyAdapter()
{
public void keyPressed(KeyEvent e)
{
int c = e.getKeyCode();
if (c == KeyEvent.VK_ESCAPE
&& ! m_comboBox.isPopupVisible())
dispose();
}
};
m_textField.addKeyListener(keyListener);
GuiUtil.setMonospacedFont(m_comboBox);
innerPanel.add(m_comboBox, BorderLayout.CENTER);
outerPanel.add(innerPanel, BorderLayout.NORTH);
return outerPanel;
}
示例6: getNameTextField
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
/**
* Return the NameTextField property value.
* @return javax.swing.JTextField
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JComboBox getNameTextField() {
if (ivjNameTextField == null) {
try {
ivjNameTextField = new javax.swing.JComboBox();
ivjNameTextField.setName("NameTextField");
// user code begin {1}
ivjNameTextField.setEditable(true);
ComboBoxEditor editor = ivjNameTextField.getEditor();
if (editor.getEditorComponent() instanceof JTextField)
{
final JTextField comboBoxTextField = (JTextField)editor.getEditorComponent();
// register event listener to the text field
comboBoxTextField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
oKButton_ActionPerformed(e);
}
});
}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
return ivjNameTextField;
}
示例7: getJComboBoxJTextField
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
public static JTextField getJComboBoxJTextField(JComboBox comboBox) {
JTextField result = null;
ComboBoxEditor cbe = comboBox.getEditor();
if (cbe != null) {
Component c = cbe.getEditorComponent();
if (c instanceof JTextField) {
result = (JTextField) c;
}
}
return result;
}
示例8: getTextComponent
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
private final JTextComponent getTextComponent()
{
final JComboBox<?> comboBox = getComboBox();
final ComboBoxEditor comboEditor = comboBox == null ? null : comboBox.getEditor();
final Component comboEditorComponent = comboEditor == null ? null : comboEditor.getEditorComponent();
if (comboEditorComponent instanceof JTextComponent)
{
return (JTextComponent)comboEditorComponent;
}
return null;
}
示例9: configureEditor
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
private final synchronized void configureEditor()
{
if (_configureEditorRunning)
{
return;
}
_configureEditorRunning = true;
try
{
if (_editorComp != null)
{
// destroy the old editor component in order to create a new one
destroyEditorComponent();
}
final ComboBoxEditor newEditor = comboBox.getEditor();
_editorComp = (JTextComponent)(newEditor == null ? null : newEditor.getEditorComponent());
if (_editorComp != null)
{
_editorComp.addKeyListener(editorKeyListener);
_editorComp.addFocusListener(editorFocusListener);
_editorComp.setDocument(ComboBoxAutoCompletion.this);
_editorComp.setInputVerifier(editorInputVerifier);
}
}
finally
{
_configureEditorRunning = false;
}
}
示例10: addEditor
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
public void addEditor() {
ComboBoxEditor cbe = comboBox.getEditor();
if (cbe == null)
return;
editor = cbe.getEditorComponent();
if (editor == null)
return;
configureEditor();
comboBox.add(editor);
}
示例11: AutoCompletionComboBoxEditor
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
public AutoCompletionComboBoxEditor(ComboBoxEditor editor) {
if ((editor.getEditorComponent() instanceof JTextField)) {
this.editor = editor;
editorComponent = (JTextField) editor.getEditorComponent();
editorComponent.getDocument().addDocumentListener(docListener);
editorComponent.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
setSelectedItem(editorComponent.getText());
actionPerformed(new ActionEvent(this, 0, "editingStoped"));
e.consume();
} else if (e.getKeyCode() == KeyEvent.VK_TAB){
if (isPopupVisible())
hidePopup();
else
showPopup();
e.consume();
} else {
super.keyPressed(e);
}
}
});
} else {
throw new IllegalArgumentException("Only JTextField allowed as editor component");
}
}
示例12: setReadable
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
private void setReadable() {
setEditable(true);
ComboBoxEditor cbxEditor = getEditor();
JTextField etf = (JTextField)cbxEditor.getEditorComponent();
etf.setDisabledTextColor(UIManager.getColor("ComboBox.foreground")); //$NON-NLS-1$
etf.setBackground(UIManager.getColor("ComboBox.background")); //$NON-NLS-1$
super.setEnabled(false);
}
示例13: setComboNumericEditor
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
/**
* Set a combo box to have a numeric editor with validation
*
* @param box The <code>JComboBox</code> to be set up
*/
protected void setComboNumericEditor(JComboBox<? extends String> box)
{
final ComboBoxEditor editor = box.getEditor();
final Component editorComponent = editor.getEditorComponent();
if (editorComponent instanceof JTextField)
{
final JTextField textField = (JTextField) editorComponent;
textField.setDocument(new CustomDocument());
}
}
示例14: processKeyBinding
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,
int condition, boolean pressed) {
mLogger.info("AttributeTable.processKeyBinding");
if (ks.getKeyCode() == KeyEvent.VK_TAB && e.getModifiers() == 0
&& pressed && getSelectedColumn() == 1
&& getSelectedRow() == getRowCount() - 1
&& getModel() instanceof ExtendedAttributeTableModelDecorator) {
insertRow(getRowCount());
return true;
}
if (ks.getKeyCode() == KeyEvent.VK_ESCAPE && e.getModifiers() == 0
&& pressed) {
attributeView.getNodeView().requestFocus();
return true;
}
boolean retValue = super.processKeyBinding(ks, e, condition, pressed);
// Start editing when a key is typed. UI classes can disable this
// behavior
// by setting the client property JTable.autoStartsEdit to
// Boolean.FALSE.
if (!retValue
&& condition == WHEN_FOCUSED
&& isFocusOwner()
&& ks.getKeyCode() != KeyEvent.VK_TAB
&& e != null
&& e.getID() == KeyEvent.KEY_PRESSED
&& !e.isActionKey()
&& e.getKeyChar() != KeyEvent.CHAR_UNDEFINED
&& 0 == (e.getModifiers() & (KeyEvent.CTRL_MASK | KeyEvent.ALT_MASK))) {
// We do not have a binding for the event.
// Try to install the editor
int leadRow = getSelectionModel().getLeadSelectionIndex();
int leadColumn = getColumnModel().getSelectionModel()
.getLeadSelectionIndex();
if (leadRow != -1 && leadColumn != -1 && !isEditing()) {
if (!editCellAt(leadRow, leadColumn)) {
return false;
}
}
Component editorComponent = getEditorComponent();
// If the editorComponent is a JComboBox, pass the event to it.
if (editorComponent instanceof JComboBox) {
JComboBox comboBox = (JComboBox) editorComponent;
if (comboBox.isEditable()) {
ComboBoxEditor editor = comboBox.getEditor();
editor.selectAll(); // to enable overwrite
KeyEvent keyEv;
keyEv = new KeyEvent(editor.getEditorComponent(),
KeyEvent.KEY_TYPED, e.getWhen(), e.getModifiers(),
KeyEvent.VK_UNDEFINED, e.getKeyChar(),
KeyEvent.KEY_LOCATION_UNKNOWN);
retValue = SwingUtilities.processKeyBindings(keyEv);
} else {
editorComponent.requestFocus();
retValue = true;
}
}
}
if (ks.getKeyCode() == KeyEvent.VK_SPACE) {
return true;
}
return retValue;
}
示例15: setEditor
import javax.swing.ComboBoxEditor; //導入方法依賴的package包/類
@Override
public void setEditor(ComboBoxEditor anEditor) {
// check if editor component has changed at all: Otherwise listener already registered
if (getEditor() == null || anEditor.getEditorComponent() != getEditor().getEditorComponent())
super.setEditor(new AutoCompletionComboBoxEditor(anEditor));
}