Ciao a tutti ero riuscito grazie hai vostri consigli a creare un tasto che salva un file .doc ma appena ho aggiunto al JLabel, su cui stampavo e scriveva il file, un JScrollPane lo salva in bianco qualcuno può aiutarmi? GRazie..
codice:
private JScrollPane scrollPane;
private JScrollPane scrollPane_1;
private JLabel STAMPA;
private JLabel STAMPA1;
public void scriviFile() {
try {
FileWriter fw = new FileWriter("file.doc");
PrintWriter out = new PrintWriter(fw);
s3 = textData.getText();
s1 = STAMPA.getText();
s2 = STAMPA1.getText();
out.print(s1);
out.print(s2);
out.print(s3);
out.close(); // chiusura File
} catch (IOException e) {}
}
codice:
JButton Save = new JButton("Save");
Save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent PRINTARE) {
String Save = PRINTARE.getActionCommand();
if (Save.equals ("Save") )
scriviFile();
STAMPA.setText ("");
STAMPA1.setText ("");
textData.setText ("_____");
}
});