List of usage examples for java.awt.event KeyAdapter KeyAdapter
KeyAdapter
From source file:Main.java
public PasswordPanel() { pwf = new JPasswordField(10); add(pwf);/*from w ww . jav a 2s. c o m*/ pwf.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { System.out.println(new String(pwf.getPassword())); } }); }
From source file:Main.java
static void setLightweightDispatcher(JComponent component) { if (dispatcherField == null) { initReflection();/*from w ww .j a v a2 s .c o m*/ } try { Object dispatcher = newLightweightDispatcher.newInstance(component); enableEvents.invoke(dispatcher, MOUSE_MASK | AWTEvent.KEY_EVENT_MASK); dispatcherField.set(component, dispatcher); component.addKeyListener(new KeyAdapter() { }); } catch (Exception e) { e.printStackTrace(); } }
From source file:PasswordFieldEchoChar.java
public PasswordPanel() { pwf = new JPasswordField(10); pwf.setEchoChar('#'); add(pwf);// www . j av a 2s . c om pwf.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { System.out.println(new String(pwf.getPassword())); } }); }
From source file:com.SCI.centraltoko.utility.UtilityTools.java
public static void setMaxLength(final int maxChar, final JTextField txtField) { txtField.addKeyListener(new KeyAdapter() { @Override//w w w . j ava 2 s . c om public void keyTyped(KeyEvent e) { batasInput(txtField, e, maxChar); } }); }
From source file:org.boaboa.vistas.FormularioVenta.java
/** * Creates new form FormularioVenta/* w w w. ja va 2s. c om*/ */ public void Nletras(JTextField a) { a.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!Character.isDigit(c)) { e.consume(); } } }); }
From source file:Main.java
public KeyTextComponent() { setBackground(Color.cyan);/*from w w w .j a v a2s . c o m*/ KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, keyText); actionListenerList.actionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocus(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:Main.java
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (comboList == null) { comboList = list;/*from w w w.j a v a 2s. co m*/ KeyAdapter listener = new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { int x = 5; int y = comboList.indexToLocation(comboList.getSelectedIndex()).y; System.out.println(comboList.getSelectedIndex()); } } }; combo.addKeyListener(listener); combo.getEditor().getEditorComponent().addKeyListener(listener); } if (isSelected) { System.out.println(value.toString()); } return this; }
From source file:MainClass.java
public KeyTextComponent() { setBackground(Color.CYAN);/* w w w . j av a 2 s. c o m*/ KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, keyText); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:Main.java
public KeyTextComponent() { setBackground(Color.CYAN);//from w w w . j a v a 2s .com KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_LAST, keyText); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:Main.java
public KeyTextComponent() { setBackground(Color.CYAN);//from w ww. j a va 2 s . c o m KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_FIRST, keyText); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }