private void NumberMinus10ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_NumberMinus10ActionPerformed int temp = Integer.parseInt(NumberField.getText()) - 10; if (temp < 0) { temp = 0; } NumberField.setText(String.valueOf(temp)); } // GEN-LAST:event_NumberMinus10ActionPerformed
private void NumberPlusTenActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_NumberPlusTenActionPerformed int temp = Integer.parseInt(NumberField.getText()) + 10; if (temp < 0) { temp = 0; } NumberField.setText(String.valueOf(temp)); // TODO add your handling code here: } // GEN-LAST:event_NumberPlusTenActionPerformed
private void BackspaceButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_BackspaceButtonActionPerformed if (NumberField.getCaretPosition() != 0) { // only do something if the caret is not the at the beginning int tmpcaretpos = NumberField.getCaretPosition(); NumberField.setText( NumberField.getText().substring(0, NumberField.getCaretPosition() - 1) + NumberField.getText() .substring(NumberField.getCaretPosition(), NumberField.getText().length())); NumberField.setCaretPosition(tmpcaretpos - 1); } } // GEN-LAST:event_BackspaceButtonActionPerformed
private void DelButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_DelButtonActionPerformed if (NumberField.getCaretPosition() != NumberField.getText().length()) { // only do something if the caret is not the at the end int tmpcaretpos = NumberField.getCaretPosition(); NumberField.setText( NumberField.getText().substring(0, NumberField.getCaretPosition()) + NumberField.getText() .substring(NumberField.getCaretPosition() + 1, NumberField.getText().length())); NumberField.setCaretPosition(tmpcaretpos); } } // GEN-LAST:event_DelButtonActionPerformed
void AppendCharacter(String character) { int tmpcaretpos = NumberField .getCaretPosition(); // save positon of the caret so we can use it again after replacing // the string NumberField.setText( NumberField.getText().substring(0, NumberField.getCaretPosition()) + character + NumberField.getText() .substring(NumberField.getCaretPosition(), NumberField.getText().length())); NumberField.setCaretPosition(tmpcaretpos + 1); // use the save caret position again NumberField.getCaret().setVisible(true); }
private void NumberClearActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_NumberClearActionPerformed NumberField.setText(""); } // GEN-LAST:event_NumberClearActionPerformed