Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using JTextField

Status
Not open for further replies.

welshone

Programmer
Jul 30, 2001
414
GB
hello,
How can I type info into a JTextField, then when I click a button pass the info. to another method ?

so far I have :

middlePanel.add(new JLabel("LastName"));
JTextField LastName = new JTextField();
middlePanel.add(LastName);

JButton Add = new JButton("Add Patron");
middlePanel.add(Add);
Add.setSize(20,10);
Add.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
DO I NEED TO PASS LASTNAME here to the METHOD ??
System.out.println("Add button pressed");
}
});


thanks for any hints.
 
Hello,
I have managed to write the values to the screen by doing
LastName.getText()

but how can I pass this to a method called :

public User(String FirstName, String LastName){
}


??

 
talking to myself now.
I think I've sorted this.
created a new user object and use the get and set methods.

but now I want to putthat value into a textarea , or table......
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top