//fix: layout, scrolling import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; import java.awt.*; import java.util.*; public class MEd implements WindowListener, ActionListener{ GridBagLayout gbl1; GridBagConstraints c; JFrame parFrame; Container contents; DocumentListener mList; JTextArea mainField; JLabel wit; JButton enterTxt; public MEd(String name, int sizx, int sizy) { gbl1=new GridBagLayout(); c=new GridBagConstraints(); c.weightx=1.0; c.fill=GridBagConstraints.BOTH; parFrame=new JFrame(name); parFrame.getContentPane().setLayout(gbl1); // mainField=new JTextArea("hello there", 3, 30); JScrollPane fieldPane=new JScrollPane(mainField); // wit= new JLabel(); enterTxt=new JButton("Relay Text"); enterTxt.addActionListener(this); parFrame.getContentPane().add(fieldPane); parFrame.getContentPane().add(wit); parFrame.getContentPane().add(enterTxt); c.gridx=0; c.gridy=3; c.gridwidth=3; gbl1.setConstraints(mainField, c); c.gridx=0; c.gridy=4; gbl1.setConstraints(enterTxt, c); c.gridx=0; c.gridy=5; gbl1.setConstraints(wit, c); parFrame.pack(); parFrame.setSize(sizx, sizy); parFrame.setVisible(true); parFrame.addWindowListener(this); } //WindowListener public void windowClosing(WindowEvent e) { Window theWindow=e.getWindow(); theWindow.dispose(); } public void windowClosed(WindowEvent e) { System.exit(0); } public void windowActivated(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowOpened(WindowEvent e) {} //ActionListener public void actionPerformed(ActionEvent e) { String thetxt=mainField.getText(); StringTokenizer firstWord=new StringTokenizer(thetxt); thetxt=firstWord.nextToken(); wit.setText(thetxt); } }