i need help with storing inputs from JTextfield into a textfile (.txt)
here is the code i have atm
JButton btnNewButton = new JButton("Search By Author");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFrame Frame1= new JFrame ("Search By Author");
Frame1.setVisible(true);
Frame1.setSize (500,200);
//Name of the Author
JTextField Name= new JTextField ("Enter Name:",30);
Name.setBounds(30, 300, 150, 20);
String Name1 = Name.getText();
JPanel Panel= new JPanel();
Frame1.getContentPane().add (Panel);
Panel.add (Name);
try {
BufferedWriter Author =null;
BufferedWriter Author2 = new BufferedWriter (new FileWriter ("./Author.txt"));
Author2.write (Name.getText());
}catch (IOException ioexception){
System.out.print ("error");
}}});
it works so ar but it wont store the inputs into the textfile