I'm trying to get value from JDateChooser
and use it as a filename
I've created a file with a path, I can write on it, but the only problem is I can't change its name to the variable(data from JDateChooser
)
Here is the part of the code:
JButton btnSave = new JButton("Save");
btnSave.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = textField.getText();
JDateChooser day = new JDateChooser();
try{
File remindFile = new File("\\path", day + ".txt");
remindFile.createNewFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(remindFile));
writer.write(text);
writer.close();
}
catch(Exception k)
{ System.out.println("Oops");}
textField.setText(null);
}
});
btnSave.setFont(new Font("Tahoma", Font.PLAIN, 13));
btnSave.setBounds(401, 215, 108, 30);
panel.add(btnSave);
In the result created file gets name as:
com.toedter.calendar.JDateChooser
[JDateChooser,0,0,0x0,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
How can I fix it?