Example usage for java.awt.event KeyEvent getKeyChar

List of usage examples for java.awt.event KeyEvent getKeyChar

Introduction

In this page you can find the example usage for java.awt.event KeyEvent getKeyChar.

Prototype

public char getKeyChar() 

Source Link

Document

Returns the character associated with the key in this event.

Usage

From source file:schoolsystem.FeeModuleDialog.java

private void txt_fee_moduleKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_fee_moduleKeyTyped
    if (evt.getKeyChar() >= '0' && evt.getKeyChar() <= '9') {

    } else {//w ww  .  j  a v  a  2 s  .  c o  m
        if (evt.getKeyChar() == KeyEvent.VK_SLASH) {

        } else {
            evt.consume();
            Toolkit.getDefaultToolkit().beep();
        }

    } // TODO add your handling 
}

From source file:schoolsystem.FeeModuleDialog.java

private void txt_fee_module_amt_paidKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_fee_module_amt_paidKeyTyped
    if (evt.getKeyChar() >= '0' && evt.getKeyChar() <= '9') {

    } else {//from   ww  w . j  a va  2s . co m
        evt.consume();
        Toolkit.getDefaultToolkit().beep();
    }
    //code here:
}

From source file:ru.codemine.pos.ui.keydispatcher.MainKeyDispatcher.java

@Override
public boolean dispatchKeyEvent(KeyEvent e) {
    WebTextField inputField = salesPanel.getChequeSetupPanel().getInputField();

    int tabIndex = mainWindow.getActiveTabIndex();
    boolean inputBlocked = mainWindow.isBarcodeInputBlocked();

    //?   ?,  ?   ????     - 
    //  ?  ? ?//  w  w  w  .  j  av a 2  s .c  om
    if (tabIndex == 0 && !inputBlocked
            && application.getCurrentScanner()
                    .getType() == BarcodeScannerDevice.BarcodeScannerType.KEYBOARD_SCANNER
            && ("1234567890".indexOf(e.getKeyChar()) >= 0)) {
        e.setSource(inputField);
    }
    //?   Enter   ? ? - ?
    //     ??  
    else if (tabIndex == 0 && !inputBlocked && !"".equals(inputField.getText())
            && (e.getKeyCode() == KeyEvent.VK_ENTER)) {
        String barcode = inputField.getText();
        inputField.clear();
        salesPanel.addProductByBarcode(barcode);
    } else {
        if (tabIndex == 0 && !inputBlocked) {
            switch (e.getKeyCode()) {
            //case KeyEvent.VK_F2 : buttonsPanel.getOpenWorkdayButton().doClick();
            //    break;
            //case KeyEvent.VK_F3 : buttonsPanel.getCloseWorkdayButton().doClick();
            //    break;
            case KeyEvent.VK_F4:
                buttonsPanel.getQuantitySetupButton().doClick();
                break;
            case KeyEvent.VK_F5:
                buttonsPanel.getChequeProcessButton().doClick();
            }
        }
    }

    return false;
}

From source file:com.sec.ose.osi.ui.dialog.setting.JPanProjectAnalysisSetting.java

/**
 * This method initializes jTextFieldUserHour
 *    /*from  w ww . ja  va2s .  c  o m*/
 * @return javax.swing.JTextField   
 */
private JTextField getJTextFieldUserHour() {
    if (jTextFieldUserHour == null) {
        jTextFieldUserHour = new JTextField();
        jTextFieldUserHour.setPreferredSize(new Dimension(80, 22));
        jTextFieldUserHour.addKeyListener(new KeyAdapter() {
            public void keyTyped(KeyEvent e) {
                char c = e.getKeyChar();
                if (!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))) {
                    getToolkit().beep();
                    e.consume();
                }
            }
        });

    }
    return jTextFieldUserHour;
}

From source file:practica1.Babage.java

private void cantidadClaveKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cantidadClaveKeyTyped
    char c = evt.getKeyChar();
    if (Character.isLetter(c)) {
        getToolkit().beep();//from   w ww  . ja v a 2s  . c o m
        evt.consume();
    }
}

From source file:practica1.Babage.java

private void textoEncriptadoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textoEncriptadoKeyTyped
    char c = evt.getKeyChar();
    if (Character.isDigit(c)) {
        getToolkit().beep();//  ww w.  j  a v  a  2  s.com
        evt.consume();
    }
}

From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java

@Override
public void keyReleased(KeyEvent e) {
    if (e.getSource() != table) {
        return;/* w  ww.  j a va  2s.  c  om*/
    }

    // Propagate event to our listeners
    processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(),
            e.getKeyLocation()));
}

From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java

@Override
public void keyTyped(KeyEvent e) {
    if (e.getSource() != table) {
        return;/*from  w ww .j a va2  s . c o m*/
    }

    // Propagate event to our listeners
    processKeyEvent(new KeyEvent(this, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(),
            e.getKeyLocation()));
}

From source file:me.mayo.telnetkek.MainPanel.java

public void setup() {
    this.txtServer.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
        @Override//from  w  w w  .  j  a  v a2  s .c o m
        public void keyTyped(KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                MainPanel.this.triggerConnect();
            }
        }
    });

    this.loadServerList();

    final URL icon = this.getClass().getResource("/icon.png");
    if (icon != null) {
        setIconImage(Toolkit.getDefaultToolkit().createImage(icon));
    }

    setupTablePopup();

    this.getConnectionManager().updateTitle(false);

    this.tblPlayers.setModel(playerListTableModel);

    this.tblPlayers.getRowSorter().toggleSortOrder(0);

    this.setLocationRelativeTo(null);
    this.setVisible(true);
}

From source file:vista.ArchToxHome.java

private void Consume(java.awt.event.KeyEvent evt) {
    char c = evt.getKeyChar();
    if (c < '0' || c > '9') {
        evt.consume();//from   www .  j  a  va2  s  .  c om
    }
}