Hi ive been trying to get the user input from the JTextField into my fileCreation class so i can name the file i am creating.
Here is the code:
public class window extends JFrame{ public static JTextField textField; public window(){ textField = new JTextField(20); add(textField); textField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String input = textField.getText(); } }); } } public class fileCreation{ public static void files ()throws IOException{ File newFile; newFile = new File("C:/Users/Administrator.Dan-HP/Desktop/" + input + ".txt"); if(!newFile.exists()){ newFile.createNewFile(); } } }
not all the code just the relevant parts.