invalidEdit
protected void invalidEdit()Invoked when the user inputs an invalid value. This gives the component a chance to provide feedback. The default implementation beeps.


isEditValid
public boolean isEditValid()Returns true if the current value being edited is valid. The value of this is managed by the current AbstractFormatter, as such there is no public setter for it.

Returns:
true if the current value being edited is valid.

ok so im using a formatted text field and what i wont is to only allow a value of >=0 && <=100
to be put into the ftf. in my code i got it doing what i wont but im trying to learn new or better was
im thinking those methods might help also a custom formatter and/or InputVerifier might work better
not sure i would just like some input
and i know that a property change listener would work
i do think i need to add a catch so that when an letter is entered it dose something useful lol.


Java Code:
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.JTextField;


public class practiceframe extends JFrame {
    JFormattedTextField textField;
	JPanel contentPane;
    String val_str;
    JSlider slider1;
    String textval;
    int textint;
    String laststr;
    private JTextField textField_1;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					practiceframe frame = new practiceframe();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public practiceframe() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		textField = new JFormattedTextField();
		textField.setText("100");
		contentPane.add(textField, BorderLayout.NORTH);
		textField.addFocusListener(new FocusAdapter() {
			
			public void focusLost(FocusEvent e) {
				JFormattedTextField slider = (JFormattedTextField)e.getSource();
                String text = slider.getText();
			    int textint = Integer.parseInt(text);
			    
			    
			    if(textint<=100&&textint>=0){
			    	slider1.setValue(textint);
			    	
			    	System.out.println("valid entry ");
			    
			    	
			    }else{
			    	 int lastint = slider1.getValue();
			    	 laststr = Integer.toString(lastint);
			    	 textField.setText(laststr);
			    	 Toolkit.getDefaultToolkit().beep(); 
			    	 JOptionPane.showMessageDialog(null,"only number value's 0 to 100 are valid","invalid value", JOptionPane.WARNING_MESSAGE);
			    	 System.out.print(textint);
			    	 System.out.println(" is not an valid entry enter a new number that is or between 0 and 100 ");
			    	 System.out.println("reterning to previous entry " + laststr);
			    	  
			    }
			}

			});
		
		textField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				JTextField slider = (JTextField)evt.getSource();
                String text = slider.getText();
			    int textint = Integer.parseInt(text);
			    
			    if(textint<=100&&textint>=0){
			    	slider1.setValue(textint);
			    	System.out.println("valid entry1");
			    
			    	
			    }else{
			    	int lastint = slider1.getValue();
			    	 laststr = Integer.toString(lastint);
			    	 textField.setText(laststr);
			    	 Toolkit.getDefaultToolkit().beep(); 
			    	 JOptionPane.showMessageDialog(null,"only number value's 0 to 100 are valid","invalid value", JOptionPane.WARNING_MESSAGE);
			    	 System.out.print(textint);
			    	 System.out.println(" is not an valid entry enter a new number that is or between 0 and 100 ");
			    	 System.out.println("reterning to previous entry " + laststr);
			    }
			    

			  

			   }
		});
		
		
		
		
		slider1 = new JSlider();
	    slider1.setValue(100);
	    contentPane.add(slider1, BorderLayout.CENTER);
	    /// ignore this its just to loss Focus on the other text field 
	    textField_1 = new JTextField();
	    contentPane.add(textField_1, BorderLayout.SOUTH);
	    textField_1.setColumns(10);
	    
	    slider1.addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent evt) {
		        JSlider slider1 = (JSlider)evt.getSource();

		        if (slider1.getValueIsAdjusting()) {
		            
		           int value = slider1.getValue();
		           int textint = Integer.parseInt( textField.getText() );
		        if(value!=textint){
		           val_str = Integer.toString(value);
		           textField.setText(val_str);
		           
		           
		        	   
		        }
		        }     
			}
		});
	}

	

}