Skip to main content

Swing data capture

1 reply [Last post]
Joined: 2010-01-10
Points: 0

Could anyone point me towards a simple program demonstrating capturing data typed into Swing components, e.g. the entry for a simple JTextfield?

All the sample I can find seem to deal with displaying the field rather than capturing the data entered .

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-05-27
Points: 0

have you tried the "getText()" method?
It's very simple, imagine you have a JTextField named "myText":
// some code
JTextField myText = new JTextField();
// some more code
Later on you can get the content the user has typed like this:
// code
String myContent = myText.getText();
// more code
More info here: