


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.accessibility.*;

public class TextArea {

    JTextField text;

    public static void main(String args[]) {
	new TextArea();
    }
    
    TextArea() {

	// create a button
	JButton button = new JButton("print text info");
	button.addActionListener(new ButtonActionListener());

	text = new JTextField("This is a text line.");
	text.setEditable(true);

	JPanel panel = new JPanel();
	panel.add(button);
	panel.add(text);

	JFrame frame = new JFrame("An editable text field.");
	frame.getContentPane().add(panel, BorderLayout.CENTER);
	frame.setSize(300, 150);
	frame.setVisible(true);
    }

    /*
     * ActionListener for button presses
     */
    class ButtonActionListener implements ActionListener {

	// called when a button is pressed
	public void actionPerformed(ActionEvent e) {
	    System.out.println("Printing text information...");
	    Rectangle rect = text.getAccessibleContext().getAccessibleComponent().getBounds();
	    System.err.println("extents = "+rect);
	}
    }

}
