Changing a property of a swing component in a jframe from a different class

Hi, I'd like to know how to change the text of a JTextArea that's in a JFrame when clicking a JButton that's in the same JFrame, but the button's actionlistener is in a separate class.

I explain:

My main class:

publicclass MyWindowextends JFrame{

//[...]

public JTextArea outPutArea =null;

private JButton clickButton =null;

//...

MyActions ba =new MyActions();

clickButton.addActionListener(ba);

/// etc.

}

// the other class

publicclass MyActionsimplements ActionListener{

// constructor

public MyActions(){

}

publicvoid actionPerformed(ActionEvent e){

//JButton foo = (JButton) e.getSource(); // only gives access to the clicked button's properties

// Change the JTextArea content

// ?

}

Thanks in advance,

Lucas

[1771 byte] By [Basureroa] at [2007-11-27 11:23:24]
# 1

Same as always - use a reference to the text field to invoke setText(). How you provide that reference is your problem, you know your app better than we do.

You could alternatively set a name to the text field, and then get your frame's children, and iterate through them to find the field...

CeciNEstPasUnProgrammeura at 2007-7-29 15:00:31 > top of Java-index,Java Essentials,Java Programming...