Monday, July 29, 2013

Handling Key Events ( adding a KEYPRESS event)

== Sample Code ===
-- consider about the code in RED --

if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            String name = txt_bSal.getText();
            if (name.trim().isEmpty()) {
                net_sal = 0 + Double.parseDouble(txt_bonus.getText());
                txt_NetSal.setText(Double.toString(net_sal));
            } else {
                net_sal = Double.parseDouble(txt_bSal.getText()) + Double.parseDouble(txt_bonus.getText());
                txt_NetSal.setText(Double.toString(net_sal));
            }
        }

No comments:

Post a Comment