jpanel change listener

hellou
is there any simple way to check changes in jpanel members (jtextfields)?

regards
interm
intermirasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
You could add an actionListener to the JTextFields and flag a boolean value.
0
ozymandiasCommented:
You can add an ActionListener to the JTextFields which will be notified when chnages occur.
0
Mayank SAssociate Director - Product EngineeringCommented:
I guess it should be a Text-listener for the JTextField, implementing the textValueChanged () method.

Mayank.
0
ozymandiasCommented:
Or a CaretListener...
0
ozymandiasCommented:
Example using a DocumentListener :

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;

public class JTextFieldExample extends JFrame{

     Container contentPane;
     JTextField jtf;

     public JTextFieldExample(String[] args){
          super("JTextFieldExample");
          this.setDefaultCloseOperation(EXIT_ON_CLOSE);
          contentPane = this.getContentPane();
          contentPane.setLayout(new BorderLayout());
          jtf = new JTextField(30);
          jtf.getDocument().addDocumentListener(new DocumentListener(){
               public void changedUpdate(DocumentEvent e){
                    System.out.println("change");
               }
               public void insertUpdate(DocumentEvent e){
                    System.out.println("insert");
               }
               public void removeUpdate(DocumentEvent e){
                    System.out.println("remove");
               }
          });
          contentPane.add(jtf,BorderLayout.NORTH);
     }

     public static void main(String[] args){
          JTextFieldExample jtfe = new JTextFieldExample(args);
          jtfe.setSize(400,400);
          jtfe.setVisible(true);
     }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.