Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

jpanel change listener

Posted on 2003-03-25
5
Medium Priority
?
410 Views
Last Modified: 2013-11-23
hellou
is there any simple way to check changes in jpanel members (jtextfields)?

regards
interm
0
Comment
Question by:intermiras
  • 3
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 8201587
You could add an actionListener to the JTextFields and flag a boolean value.
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 8201602
You can add an ActionListener to the JTextFields which will be notified when chnages occur.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8201622
I guess it should be a Text-listener for the JTextField, implementing the textValueChanged () method.

Mayank.
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 8201647
Or a CaretListener...
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 750 total points
ID: 8201728
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question