本文整理匯總了Java中javax.swing.ComboBoxEditor類的典型用法代碼示例。如果您正苦於以下問題:Java ComboBoxEditor類的具體用法?Java ComboBoxEditor怎麽用?Java ComboBoxEditor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ComboBoxEditor類屬於javax.swing包,在下文中一共展示了ComboBoxEditor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Test
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
public Test() {
JFrame f = new JFrame("JComboBox");
Container contentPane = f.getContentPane();
JComboBox combo = new JComboBox(fontsize);
combo.setBorder(BorderFactory.createTitledBorder("請選擇你要的文字大小"));
combo.setEditable(true);// 將JComboBox設成是可編輯的.
ComboBoxEditor editor = combo.getEditor();// getEditor()方法返回ComboBoxEditor對象,如果你查看手冊,你就會發
// 現ComboBoxEditor是個接口(interface),因此你可以自行實作這個接口,製作自己想要的ComboBoxEditor組件。但通常
// 我們不需要這麽做,因為默認的ComboBoxEditor是使用JTextField,這已經足夠應付大部份的情況了。
// configureEditor()方法會初始化JComboBox的顯示項目。例如例子中一開始就出現:"請選擇或直接輸入文字大小!"這個
// 字符串。
combo.configureEditor(editor, defaultMessage);
contentPane.add(combo);
f.pack();
f.show();
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
示例2: setInfos
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
private void setInfos() {
passwordField.setEchoChar('*');
names.setEditable(true);// 將JComboBox設成是可編輯的.
ComboBoxEditor editor = names.getEditor();
names.configureEditor(editor, "");
names.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (names.getItemCount() == 0)
return;
if (e.getKeyCode() == KeyEvent.VK_DELETE) {
nameController.deleteName((String) names.getSelectedItem());
updateNames();
repaint();
}
}
});
}
示例3: search
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
/**
* Executes a search operation.
*
* @param parent Parent window used for dialogs.
* @param editor Combobox editor whose color is changed depending on the search result.
* @param graph Graph to search through.
* @param searcher Executes the search over the graph.
* @param searchString The string to search for.
* @param cycleBackwards True, to cycle backwards through the results. False, to cycle in forward
* order.
* @param zoomToResult True, to zoom to a result. False, to move without zooming.
*/
public static void search(final Window parent,
final ComboBoxEditor editor,
final ZyGraph graph,
final GraphSearcher searcher,
final String searchString,
final boolean cycleBackwards,
final boolean zoomToResult) {
// If something in the searcher changed, we have to recalculate
// the search results.
if (searcher.hasChanged() || !searchString.equals(searcher.getLastSearchString())) {
CSearchExecuter.startNewSearch(parent, editor, graph, searcher, searchString, zoomToResult);
} else if (!searcher.getResults().isEmpty()) // Don't bother cycling through an empty results
// list
{
CSearchExecuter.cycleExistingSearch(parent, graph, searcher, cycleBackwards, zoomToResult);
}
}
示例4: 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);
}
}
示例5: propertyChange
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
/**
* Called when the combos editor changes
*
* @param evt
* A PropertyChangeEvent object describing the event source
* and the property that has changed.
*/
public void propertyChange(PropertyChangeEvent evt) {
ComboBoxEditor newEditor = comboBox.getEditor();
if (editor != newEditor) {
if (editorComponent != null) {
editorComponent.removeFocusListener(this);
}
editor = newEditor;
if (editor != null) {
editorComponent = editor.getEditorComponent();
if (editorComponent != null) {
editorComponent.addFocusListener(this);
}
}
}
}
示例6: updateMenu
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
public void updateMenu() {
ComboBoxEditor editor = getEditor();
Object value =editor.getItem();
removeAllItems();
if(isEditable()){
if (value != null) {
addItem((T)value);
setSelectedIndex(0);
}
}
List<T> items = getAvailableItems();
if (items != null) {
for (T field : items) {
// if (value == null || value.toString().equals(field) == false) {
addItem(field);
// }
}
}
}
示例7: applyContext
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
protected void applyContext(AbstractListBinding binding, Map context) {
super.applyContext(binding, context);
ComboBoxBinding comboBoxBinding = (ComboBoxBinding) binding;
if (context.containsKey(RENDERER_KEY)) {
comboBoxBinding.setRenderer((ListCellRenderer) decorate(context.get(RENDERER_KEY), comboBoxBinding
.getRenderer()));
} else if (renderer != null) {
comboBoxBinding.setRenderer((ListCellRenderer) decorate(renderer, comboBoxBinding.getRenderer()));
}
if (context.containsKey(EDITOR_KEY)) {
comboBoxBinding.setEditor((ComboBoxEditor) decorate(context.get(EDITOR_KEY), comboBoxBinding.getEditor()));
} else if (editor != null) {
comboBoxBinding.setEditor((ComboBoxEditor) decorate(editor, comboBoxBinding.getEditor()));
}
if (context.containsKey(EMPTY_SELECTION_VALUE)) {
comboBoxBinding.setEmptySelectionValue(context.get(EMPTY_SELECTION_VALUE));
} else if (emptySelectionValue != null) {
comboBoxBinding.setEmptySelectionValue(emptySelectionValue);
}
}
示例8: 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;
}
示例9: constructPanel
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
private void constructPanel(String[] values) {
// constructing editors
editors = new PropertyValueCellEditor[types.length];
for (int i = 0; i < types.length; i++) {
editors[i] = PropertyPanel.instantiateValueCellEditor(types[i], operator);
}
// building panel
panel = new JPanel();
panel.setFocusable(true);
panel.setLayout(new GridLayout(1, editors.length));
for (int i = 0; i < types.length; i++) {
Component editorComponent = editors[i].getTableCellEditorComponent(null, values[i], false, 0, 0);
if (editorComponent instanceof JComboBox && ((JComboBox) editorComponent).isEditable()) {
if (((JComboBox) editorComponent).isEditable()) {
ComboBoxEditor editor = ((JComboBox) editorComponent).getEditor();
if (editor instanceof BasicComboBoxEditor) {
editor.getEditorComponent().addFocusListener(focusListener);
}
} else {
editorComponent.addFocusListener(focusListener);
}
} else if (editorComponent instanceof JPanel) {
JPanel editorPanel = (JPanel) editorComponent;
Component[] components = editorPanel.getComponents();
for (Component comp : components) {
comp.addFocusListener(focusListener);
}
} else {
editorComponent.addFocusListener(focusListener);
}
panel.add(editorComponent);
panel.addFocusListener(focusListener);
}
}
示例10: 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");
}
}
示例11: 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));
}
}
示例12: AnnotationSetNameComboEditor
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
AnnotationSetNameComboEditor(ComboBoxEditor realEditor) {
this.realEditor = realEditor;
normalFont = realEditor.getEditorComponent().getFont();
italicFont = normalFont.deriveFont(Font.ITALIC);
setItem(null, false);
realEditor.getEditorComponent().addFocusListener(this);
}
示例13: configureEditor
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
/**
* Maps {@code JComboBox.configureEditor(ComboBoxEditor, Object)}
* through queue
*/
public void configureEditor(final ComboBoxEditor comboBoxEditor, final Object object) {
runMapping(new MapVoidAction("configureEditor") {
@Override
public void map() {
((JComboBox) getSource()).configureEditor(comboBoxEditor, object);
}
});
}
示例14: getEditor
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
/**
* Maps {@code JComboBox.getEditor()} through queue
*/
public ComboBoxEditor getEditor() {
return (runMapping(new MapAction<ComboBoxEditor>("getEditor") {
@Override
public ComboBoxEditor map() {
return ((JComboBox) getSource()).getEditor();
}
}));
}
示例15: setEditor
import javax.swing.ComboBoxEditor; //導入依賴的package包/類
/**
* Maps {@code JComboBox.setEditor(ComboBoxEditor)} through queue
*/
public void setEditor(final ComboBoxEditor comboBoxEditor) {
runMapping(new MapVoidAction("setEditor") {
@Override
public void map() {
((JComboBox) getSource()).setEditor(comboBoxEditor);
}
});
}