0

So I have a class that contains a JTextField, I reference it using .getField(). When I try to add a listener to it the listener doesn't fire(no error messages. When i add the listener inside the class that defines workspace, everything works. Any ideas?

    workspace.getField().getDocument()
            .addDocumentListener(new DocumentListener() {
                public void changedUpdate(DocumentEvent e) {
                    changed();
                }

                public void removeUpdate(DocumentEvent e) {
                    changed();
                }

                public void insertUpdate(DocumentEvent e) {
                    changed();
                }

                public void changed() {
                    System.out.println("changed");
                }
            });

.getField():

public class ACTTextBox {
    //custom UI for textbox and label
    JTextField input;
    JLabel name;
    public ACTTextBox(int x, int y, int width, int height,String Name){
        input = new JTextField();


name = new JLabel(Name+":");


    }

    public JTextField getField(){return input;}    


public void addTo(JPanel panel){
        panel.add(name);
        panel.add(input);   
    }   
}
Tony Li
  • 137
  • 1
  • 10

0 Answers0