I\'m trying to make input nameField appear in a Label called label1 after a Button called button1 is clicked
the getText method returns a String, while the setText receives a String, so you can write it like label1.setText(nameField.getText()); in your listener.
You are setting the label text before the button is clicked to "txt". Instead when the button is clicked call setText() on the label and pass it the text from the text field.
Example:
label1.setText(nameField.getText());
Setup a DocumentListener on nameField. When nameField is updated, update your label.
http://download.oracle.com/javase/1.5.0/docs/api/javax/swing/JTextField.html
in your action performed method, call:
label1.setText(nameField.getText());
This way, when the button is clicked, label will be updated to the nameField text.