Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Value Change Listener to JTextField

// Listen for changes in the text
textField.getDocument().addDocumentListener(new DocumentListener() {
  public void changedUpdate(DocumentEvent e) {
    warn();
  }
  public void removeUpdate(DocumentEvent e) {
    warn();
  }
  public void insertUpdate(DocumentEvent e) {
    warn();
  }

  public void warn() {
     if (Integer.parseInt(textField.getText())<=0){
       JOptionPane.showMessageDialog(null,
          "Error: Please enter number bigger than 0", "Error Message",
          JOptionPane.ERROR_MESSAGE);
     }
  }
});
Comment

PREVIOUS NEXT
Code Example
Java :: all possible substrings of a string java of specific length 
Java :: java use parent method 
Java :: jdk jre jvm 
Java :: return random boolean 
Java :: Java if...else 
Java :: where to use findviewbyid in fragment 
Java :: java try...catch 
Java :: permutation and combination program in java 
Java :: maths.random in Java 
Java :: hibernate onetone with mapsid 
Java :: java load jar at runtime 
Java :: stringbuilder java setlength 
Java :: how to create a node in java 
Java :: Java empty() Method 
Java :: hash map java 
Java :: set style programmatically android 
Java :: java complex numbers 
Java :: final variable java 
Java :: java how to split a string to array 
Java :: get node inside node in of xml using java 
Java :: java float data type 
Java :: can we have abstract class having no abstract method in java? 
Java :: stringbuilder example in java 
Java :: recursion java fibonacci 
Java :: how to divide a double in java 
Java :: how to encrypt password in properties file in spring boot 
Java :: java eth 
Java :: how to Compile the source code in ./src folder with libraries in ./lib folder using JavaSE-1.7 
Java :: java regex of eauations 
Java :: java modulus opperation 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =