I am writing a swing application that has a main application frame,
plus up to three additional frames that it creates.  In my main
frame, I have a JTextArea, and I would like to append text from
any of the other three frames into this text area.  Here are some
code fragments:

========================================================================
class SubFrame extends JFrame implements ActionListener {
        public SubFrame() {
                // construct sub frame
        }

        public void actionPerformed(ActionEvent e) {
                if (some_action) {
                        //
                        // append some text to outputText of MainFrame
                        // This is where I need help!
                        //
                }
        }
}

class MainFrame extends JFrame implements ActionListener {

        JTextArea outputText;
        JScrollPane outputPanel;

        public MainFrame() {
                //
                // create the output text area
                //
                outputText = new JTextArea(6, 20);
                outputPanel = new JScrollPane(outputText);
                getContentPane().add(outputPanel, BorderLayout.SOUTH);
        }

        public void actionPerformed(ActionEvent e) {
                if (some_action) {
                        subFrame = new SubFrame();
                        subFrame.setVisible(true);
                }
        }
}
========================================================================

My question is, how do I reference "outputText" from the SubFrame class?
I tried MainFrame.outputText.append(), but that didn't work.  Do I need
to write a method of MainFrame, or can I simply reference outputText
somehow outside of MainFrame?

Any help would be appreciated.

Rich

_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to