Java Code Examples for javax.swing.JComponent#addKeyListener()
The following examples show how to use
javax.swing.JComponent#addKeyListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorWellUI.java From pumpernickel with MIT License | 6 votes |
@Override public void installUI(JComponent c) { c.addFocusListener(repaintFocusListener); c.addMouseListener(mouseListener); c.addMouseMotionListener(mouseListener); c.addKeyListener(keyListener); JColorWell well = (JColorWell) c; ColorChangeListener ccl = new ColorChangeListener(c); listenerMap.put(well, ccl); well.getColorSelectionModel().addChangeListener(ccl); ShowColorPaletteActionListener colorPaletteActionListener = new ShowColorPaletteActionListener(); c.putClientProperty(DOUBLE_CLICK_ACTION_PROPERTY, colorPickerActionListener); c.putClientProperty(SPACE_KEY_ACTION_PROPERTY, colorPickerActionListener); c.putClientProperty(SINGLE_CLICK_ACTION_PROPERTY, colorPaletteActionListener); c.putClientProperty(DOWN_KEY_ACTION_PROPERTY, colorPaletteActionListener); }
Example 2
Source File: PaletteUI.java From pumpernickel with MIT License | 6 votes |
@Override public void installUI(JComponent c) { super.installUI(c); c.addPropertyChangeListener(JPalette.PROPERTY_COLORS, propertyLayoutListener); c.addPropertyChangeListener(PaletteUI.PROPERTY_HIGHLIGHT, propertyRepaintListener); c.setLayout(new PaletteLayoutManager()); c.setRequestFocusEnabled(true); c.addMouseListener(mouseListener); c.addFocusListener(focusListener); c.addKeyListener(keyListener); c.setFocusable(true); Fields fields = getFields((JPalette) c, true); fields.install(); c.setBorder(new CompoundBorder(new LineBorder(new Color(0xB0B0B0)), new FocusedBorder(getDefaultBorder()))); relayoutCells((JPalette) c); }
Example 3
Source File: ComboBoxCellEditor.java From cropplanning with GNU General Public License v3.0 | 6 votes |
/** * Creates a new ComboBoxCellEditor. * @param comboBox the comboBox that should be used as the cell editor. */ public ComboBoxCellEditor(final JComboBox comboBox) { this.comboBox = comboBox; handler = new Handler(); // Don't do this: // this.comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); // it probably breaks various things // hitting enter in the combo box should stop cellediting JComponent editorComponent = (JComponent) comboBox.getEditor().getEditorComponent(); editorComponent.addKeyListener(handler); // remove the editor's border - the cell itself already has one editorComponent.setBorder(null); // editor component might change (e.g. a look&feel change) // the new editor component needs to be modified then (keyListener, border) comboBox.addPropertyChangeListener(handler); }
Example 4
Source File: WritingTextArea.java From pumpernickel with MIT License | 5 votes |
@Override public void installUI(JComponent c) { super.installUI(c); c.addKeyListener(keyListener); c.addMouseListener(mouseListener); layout.addPropertyChangeListener(layoutListener); }
Example 5
Source File: DialogFooter.java From pumpernickel with MIT License | 5 votes |
private static void addFocusArrowListener(JComponent jc) { /** * Check to see if someone already added this kind of listener: */ KeyListener[] listeners = jc.getKeyListeners(); for (int a = 0; a < listeners.length; a++) { if (listeners[a] instanceof FocusArrowListener) return; } // Add our own: jc.addKeyListener(new FocusArrowListener()); }
Example 6
Source File: MultiThumbSliderUI.java From pumpernickel with MIT License | 5 votes |
@Override public void installUI(JComponent slider) { slider.addMouseListener(this); slider.addMouseMotionListener(this); slider.addFocusListener(focusListener); slider.addKeyListener(keyListener); slider.addComponentListener(compListener); slider.addPropertyChangeListener(propertyListener); slider.addPropertyChangeListener(THUMB_SHAPE_PROPERTY, thumbShapeListener); calculateGeometry(); }
Example 7
Source File: MultiThumbSliderUI.java From PyramidShader with GNU General Public License v3.0 | 5 votes |
@Override public void installUI(JComponent slider) { slider.addMouseListener(this); slider.addMouseMotionListener(this); slider.addFocusListener(focusListener); slider.addKeyListener(keyListener); slider.addComponentListener(compListener); slider.addPropertyChangeListener(propertyListener); slider.addPropertyChangeListener(THUMB_SHAPE_PROPERTY, thumbShapeListener); calculateGeometry(); }
Example 8
Source File: SwingRendererImpl.java From birt with Eclipse Public License 1.0 | 5 votes |
@Override public void setProperty( String sProperty, Object oValue ) { // InteractiveRenderer(iv) is only for Swing if ( sProperty.equals( IDeviceRenderer.UPDATE_NOTIFIER ) && iv != null ) { _iun = (IUpdateNotifier) oValue; iv.setUpdateNotifier( _iun ); _lhmAllTriggers.clear( ); Object obj = _iun.peerInstance( ); if ( obj instanceof JComponent ) { JComponent jc = (JComponent) obj; if ( _eh != null ) { // We can't promise to remove all the old swtEventHandler // due to SWT limitation here, so be sure to just attach the // update_notifier only to one renderer. jc.removeMouseListener( _eh ); jc.removeMouseMotionListener( _eh ); jc.removeKeyListener( _eh ); jc.removeFocusListener( _eh ); } _eh = new SwingEventHandler( iv, _lhmAllTriggers, _iun, getULocale( ) ); jc.addMouseListener( _eh ); jc.addMouseMotionListener( _eh ); jc.addKeyListener( _eh ); jc.addFocusListener( _eh ); } } super.setProperty( sProperty, oValue ); }
Example 9
Source File: ComboBoxCellEditor.java From cropplanning with GNU General Public License v3.0 | 5 votes |
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("editor")) { ComboBoxEditor editor = comboBox.getEditor(); if (editor!=null && editor.getEditorComponent()!=null) { JComponent editorComponent = (JComponent) comboBox.getEditor().getEditorComponent(); editorComponent.addKeyListener(this); editorComponent.setBorder(null); } } }
Example 10
Source File: WorkgroupDataForm.java From Spark with Apache License 2.0 | 5 votes |
private void addField(String label, JComponent comp, String variable) { if (!(comp instanceof JCheckBox)) { this.add(new JLabel(label), new GridBagConstraints(0, row, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } if (comp instanceof JTextArea) { this.add(new JScrollPane(comp), new GridBagConstraints(1, row, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 100, 50)); } else if (comp instanceof JCheckBox) { this.add(comp, new GridBagConstraints(0, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } else if (comp instanceof CheckBoxList) { this.add(comp, new GridBagConstraints(1, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 50)); } else { this.add(comp, new GridBagConstraints(1, row, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } valueMap.put(variable, comp); row++; comp.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if(e.getKeyChar() == KeyEvent.VK_ENTER){ if(listener != null){ listener.enterPressed(); } } } }); }
Example 11
Source File: RightAngleBoxContainerPanelUI.java From pumpernickel with MIT License | 4 votes |
@Override public void installUI(JComponent c) { super.installUI(c); c.setFocusable(true); c.addKeyListener(keyListener); }
Example 12
Source File: StatusBarPhaseDisplay.java From megamek with GNU General Public License v2.0 | 4 votes |
protected void addBag(JComponent comp, GridBagLayout gridbag, GridBagConstraints c) { gridbag.setConstraints(comp, c); add(comp); comp.addKeyListener(this); }