So far this what i got.
I want to limit the length of inputted values into a textfield up to 7 digits.
With this code, the inputted values goes on and on. it is not limiting it to only 7. Only what is displayed, thAt it will show 7 digits. When sum button is click. it adds up all the digits inputted.
What I want is that, I can input up tp 7 digits only.
THANKS
private void jButtonSubtractActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double A;
double B;
int MAX_LEN = 7;
try {
A = Double.parseDouble(
this.jTextField1.getText());
if(jTextField1.getText().length() > MAX_LEN);
{
jTextField1.setText(jTextField1.getText().substring(0, MAX_LEN ));
}
}

New Topic/Question
Reply




MultiQuote



|