Applying DocumentListener on multiple JTextField Say I have 5 JTextField: jTextField1, jTextField2...

Now I want them to behave the same on DocumentListener, so I decided to make only one DocumentListener and set it to the 5 components.

Meanwhile I'm doing this:

jTextField1.getDocument().putProperty("owner", jTextField1); 
jTextField2.getDocument().putProperty("owner", jTextField2); 
..
..


And I have this listener:

DocumentListener documentListener = new DocumentListener() { 
    public void changedUpdate(DocumentEvent arg0) 
    {
        Object owner = arg0.getDocument().getProperty("owner");
        enableDetachButton(getContentPane());
        changeColor((JTextField) owner);
    }

    public void insertUpdate(DocumentEvent arg0) 
    {
        Object owner = arg0.getDocument().getProperty("owner");
        enableDetachButton(getContentPane());
        changeColor((JTextField) owner);
    }

    public void removeUpdate(DocumentEvent arg0) 
    {
        Object owner = arg0.getDocument().getProperty("owner");
        enableDetachButton(getContentPane());
        changeColor((JTextField) owner);
    }   
};


Finally, I do:

jTextField1.getDocument().addDocumentListener(documentListener);
..
..


Is this approach OK? What improvements can I do?
Almost fine. You are doing the same stuff in all 3 update methods of the DocumentListener, so I suggest creating a new private method in it and just calling it from all 3 update methods. That way you avoid code duplication and only have one location to change in the future instead of having to maintain the same code 3 times.

DocumentListener listener = new DocumentListener() {

    @Override
    public void removeUpdate(DocumentEvent e) {
        doStuff(e);
    }

    @Override
    public void insertUpdate(DocumentEvent e) {
        doStuff(e);
    }

    @Override
    public void changedUpdate(DocumentEvent e) {
        doStuff(e);
    }

    private void doStuff(DocumentEvent e) {
        Object owner = e.getDocument().getProperty("owner");
        enableDetachButton(getContentPane());
        changeColor((JTextField) owner);
    }
});