Example usage for java.awt.event KeyEvent isActionKey

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

Introduction

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

Prototype

public boolean isActionKey() 

Source Link

Document

Returns whether the key in this event is an "action" key.

Usage

From source file:nz.dataview.websyncclientgui.WebSYNCClientGUIView.java

private void onAdvancedConfigFieldChanged(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_onAdvancedConfigFieldChanged
    if (!advancedSaveButton.isEnabled() && !evt.isActionKey()) {
        // flag to require restart
        requiresRestart = fieldChangeRequiresRestart(evt);

        //    if (evt.getSource() == authenticationKeyField) {
        //       confAuthKeyField.setEnabled(true);
        //    }/* w  w w .  jav  a2  s . com*/
        // a configuration was modified, lets enable the save button
        advancedSaveButton.setEnabled(true);
    }

}

From source file:org.yccheok.jstock.gui.JStock.java

private void jTable1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyPressed
    if (KeyEvent.VK_DELETE == evt.getKeyCode()) {
        this.deteleSelectedTableRow();
        return;//  w  ww .j a va  2 s  . c  o  m
    } else if (KeyEvent.VK_ENTER == evt.getKeyCode()) {
        displayHistoryCharts();
        return;
    } else if (evt.isActionKey()) {
        int[] rows = JStock.this.jTable1.getSelectedRows();

        if (rows.length == 1) {
            int row = rows[0];

            final StockTableModel tableModel = (StockTableModel) jTable1.getModel();
            final int modelIndex = jTable1.convertRowIndexToModel(row);
            final Stock stock = tableModel.getStock(modelIndex);
            this.updateDynamicChart(stock);
        } else {
            this.updateDynamicChart(null);
        }
    }
}

From source file:org.yccheok.jstock.gui.MainFrame.java

private void jTable1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyPressed
    if (KeyEvent.VK_DELETE == evt.getKeyCode()) {
        this.deteleSelectedTableRow();
        return;/* www.  j a  va 2  s.com*/
    }

    if (evt.isActionKey()) {
        int[] rows = MainFrame.this.jTable1.getSelectedRows();

        if (rows.length == 1) {
            int row = rows[0];

            final StockTableModel tableModel = (StockTableModel) jTable1.getModel();
            final int modelIndex = jTable1.convertRowIndexToModel(row);
            final Stock stock = tableModel.getStock(modelIndex);
            this.updateDynamicChart(stock);
        } else {
            this.updateDynamicChart(null);
        }
    }
}

From source file:tax.MainForm.java

private void dateTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dateTextKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        if (!dateText.getText().equals("")) {
            Util.fadeInAndOut(dateText, Util.darkGreen);

            priceText.setEnabled(true);/*from w w w.  j  av  a  2 s.co  m*/
            priceText.requestFocus();
        } else
            Util.fadeInAndOut(dateText, Util.darkOrange);
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = dateText.getText();
                int dateLength = text.length();

                while (lastDateTextLength == dateLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastDateTextLength + " " + dateLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = dateText.getText();
                    dateLength = text.length();
                }
                try {
                    int num = Integer.decode(text);
                    if (num > 31) {
                        if (text.length() > 0)
                            dateText.setText(text.substring(0, dateLength - 1));
                        else
                            dateText.setText("");
                        return;
                    }
                } catch (Exception e) {
                    if (text.length() > 0)
                        dateText.setText(text.substring(0, dateLength - 1));
                    else
                        dateText.setText("");
                    return;
                }
                lastDateTextLength = dateLength;
            }
        });
    }
}

From source file:tax.MainForm.java

private void priceTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_priceTextKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        if (!priceText.getText().equals("")) {
            Util.fadeInAndOut(priceText, Util.darkGreen);

            afmText.setEnabled(true);/* w  w  w  .j  a v a  2  s. c  o m*/
            afmText.requestFocus();
        } else
            Util.fadeInAndOut(priceText, Util.darkOrange);
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = priceText.getText();
                int priceLength = text.length();

                while (lastPriceTextLength == priceLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastPriceTextLength + " " + priceLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = priceText.getText();
                    priceLength = text.length();
                }

                //                    if (text.charAt(priceLength - 1) == '\u002c')
                //                        priceText.setText(text.substring(0, priceLength - 1) + ".");

                try {
                    Double.parseDouble(text);
                } catch (Exception e) {
                    if (text.length() > 0) {
                        //                            System.out.println(text.charAt(priceLength - 1));
                        priceText.setText(text.substring(0, priceLength - 1));
                    } else
                        priceText.setText("");
                    return;
                }
                lastPriceTextLength = priceLength;
            }

        });
    }
}

From source file:tax.MainForm.java

private void afmTextKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextKeyPressed
    String text = afmText.getText();

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        if (text.length() == 9) {

            for (Object key : afmToName.keySet()) {
                if (afmToName.get(key).equals(text))
                    nameText.setText(key.toString());
            }//from w  w w  .j a v  a 2  s .  c o m

            //                Util.fadeInAndOut(afmText, Util.darkGreen);
            addRowBut.doClick();
        } else if (text.length() == 0) {
            Util.fadeInAndOut(afmText, Color.white);
            nameText.setEnabled(true);
            nameText.requestFocus();
        } else
            Util.fadeInAndOut(afmText, Util.darkOrange);
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = afmText.getText();
                int afmLength = text.length();

                while (lastAFMTextLength == afmLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastAFMTextLength + " " + afmLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = afmText.getText();
                    afmLength = text.length();
                }

                try {
                    int num = Integer.decode(text);
                    if (afmLength > 9) {
                        if (text.length() > 0)
                            afmText.setText(text.substring(0, afmLength - 1));
                        else
                            afmText.setText("");
                        return;
                    }
                } catch (Exception e) {
                    if (text.length() > 0)
                        afmText.setText(text.substring(0, afmLength - 1));
                    else
                        afmText.setText("");
                    return;
                }

                lastAFMTextLength = afmLength;
            }
        });
    }
}

From source file:tax.MainForm.java

private void afmTextSKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_afmTextSKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        String text = afmTextS.getText();

        if (text.length() == 9) {
            try {
                int num = Integer.parseInt(text);
            } catch (Exception e) {
                afmTextS.setText("");
                return;
            }//w  w w  .j a  v a  2s. c  o  m

            //                Util.fadeInAndOut(afmTextS, Util.darkGreen);
            addNameBut.doClick();
        } else {
            Util.fadeInAndOut(afmTextS, Util.darkOrange);
        }
    } else if (!evt.isActionKey() && !evt.isAltDown() && !evt.isControlDown() && !evt.isShiftDown()
            && !evt.isMetaDown() && (evt.getKeyCode() != KeyEvent.VK_BACK_SPACE)
            && (evt.getKeyCode() != KeyEvent.VK_DELETE) && (evt.getKeyCode() != KeyEvent.VK_ESCAPE)) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                String text = afmTextS.getText();
                int afmLength = text.length();

                while (lastAFMTextSLength == afmLength) {
                    try {
                        Thread.sleep(100);
                        System.out.println("text: " + text);
                        System.out.println(lastAFMTextSLength + " " + afmLength);
                        return;
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    text = afmTextS.getText();
                    afmLength = text.length();
                }

                try {
                    int num = Integer.decode(text);
                    if (afmLength > 9) {
                        if (text.length() > 0)
                            afmTextS.setText(text.substring(0, afmLength - 1));
                        else
                            afmTextS.setText("");
                        return;
                    }
                } catch (Exception e) {
                    if (text.length() > 0)
                        afmTextS.setText(text.substring(0, afmLength - 1));
                    else
                        afmTextS.setText("");
                    return;
                }

                lastAFMTextSLength = afmLength;
            }
        });
    }
}