Hi i am new to Using JFrame & Action Listener,
I want to get input from more than 20 fields and then I need to store it in a database.
I Perform those storing operation in an ActionEvent
Class Dialog_Box
{
JTextField Name; //1st TextField
JTextField Place; //2nd TextField
JTextField City; //3rd TextField
JTextField Country; //4th
.
.
.
JTextField Pincode; //20th TextField
Dialog_Box()
{
JButton Add = new JButton(
{
public void Action Performed()
{
String Name_data=Name.getText();//Getting first input
String Place_data=Place.getText();
.
.
.
String Pincode=Pincode.getText();//Getting 20th input
//Storing these data in Database
}
});
}
}
Here as my TextField
data needed to be used in two methods (Constructor
method and ActionPerformed
method), I am declaring those Textfields universally.
But i don't want to declare it universally. Is there any other way to declare those TextFields?