0
all right? Can anyone tell me how to do, when I click the save button, open the "saveAs" screen of Windows itself? In the code, I’m saving in a fixed place, but I want to open the screen and choose where to save. (Obs: I’ve done it with Jfilechooser, but I didn’t really like the screen interface)
private void salvarTxt(){
String caminho = "";
if((jTextField1.getText().isEmpty()) || (jTextField2.getText().isEmpty())){
JOptionPane.showMessageDialog(null, "Preencha todos os campos!");
}else{
String nome = JOptionPane.showInputDialog("Digite um nome para salvar o arquivo");
try {
File fl = new File("C:/Users/Rogério/Documents/"+ nome +".txt");
PrintWriter pw = new PrintWriter(fl);
pw.println(jTextField2.getText());
pw.println(jTextField1.getText());
pw.close();
JOptionPane.showMessageDialog(null, "Dados salvos com sucesso!");
jTextField1.setText(null);
jTextField2.setText(null);
}catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}
With graphical and swing interface, only with Jfilechooser to achieve this.
– user28595
Or if you can create an implementation of this from scratch, which would be silly since Jfilechooser takes good care of it.
– user28595