//fix: layout import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; import java.awt.*; public class MEd implements WindowListener, ActionListener{ GridBagLayout gbl1; GridBagConstraints c; JFrame parFrame; Container contents; 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); contents=new Container(); contents.setLayout(gbl1); mainField=new JTextArea(); wit= new JLabel(); enterTxt=new JButton("Relay Text"); enterTxt.addActionListener(this); contents.add(mainField); contents.add(wit); contents.add(enterTxt); c.gridx=0; c.gridy=3; c.gridwidth=3; c.gridheight=3; gbl1.setConstraints(mainField, c); c.gridx=0; c.gridy=4; c.gridwidth=1; c.gridheight=1; gbl1.setConstraints(enterTxt, c); c.gridx=3; c.gridy=5; gbl1.setConstraints(wit, c); parFrame.getContentPane().add(contents); parFrame.pack(); parFrame.setSize(sizx, sizy); parFrame.setVisible(true); } //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(); wit.setText(thetxt); } }