ti ringrazio dei tuoi consigli adesso l'ho fatto cosi pero mi da errore su
codice:
 new Text();
dice che "Exception java.io.IOException must be caught, or it must be declared in the throws clause of this method." non sono molto esperto e non so cosa manca.


codice:
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import java.awt.*;
import java.applet.*;
import java.io.*;

public class testo extends Applet
{
    TextArea TA=new TextArea();
    Label L1=new Label();
    Label L2=new Label();
   
    public void init()
    {
        add(L1,BorderLayout.NORTH);
        add(TA,BorderLayout.CENTER);
        add(L2,BorderLayout.SOUTH);
        L1.setText("Inserisci un testo da salvare su file. ENTER per salvare");
        TA.addKeyListener(new MyKeyListener());
    }

    class MyKeyListener implements KeyListener
    {
        public void keyReleased(KeyEvent e)
        {
            int valore=e.getKeyCode();
            if (valore==10)
            {
                new Text();
            }
        }
        public void keyTyped(KeyEvent e)
        {
        }
        public void keyPressed(KeyEvent e)
        {
        }
    }
    
    class Text
    {
        public Text() throws IOException 
        {
            try
            {
                PrintStream ps = new PrintStream( new FileOutputStream("testosalvato.txt") );
                ps.println(TA.getText());
                ps.close();
                L2.setText("Testo salvato in testosalvato.txt");
            }
            catch (Exception f)
            {
                f.printStackTrace();
            }
        } 
    }
}