I want to have two text fields that will have the following checks
- Both must be intact
- The value in one text field must be an integer multiple of another
I used two JFormattedTextFields. This is what I have done so far.
NumberFormat updateFormat,sampleFormat; updateFormat = NumberFormat.getNumberInstance(); updateFormat.setMaximumFractionDigits(0); updateFormat.setParseIntegerOnly(true); sampleFormat = NumberFormat.getNumberInstance(); sampleFormat.setMaximumFractionDigits(0); sampleFormat.setParseIntegerOnly(true); javax.swing.JFormattedTextField jFormattedTextField1 =new javax.swing.JFormattedTextField(updateFormat); javax.swing.JFormattedTextField jFormattedTextField2 = new javax.swing.JFormattedTextField(sampleFormat);
With this help, my first part is completed. Now I am stuck with the second part, i.e. The value of jFormattedTextField1 must be an integer multiple of jFormattedTextField2. I think I need to customize my NumberFormat by expanding it. But how do I do this? Please help me
source share