本文整理汇总了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);
}
});
}