import java.awt.*;
import java.applet.*;
import java.util.Scanner;
import java.io.*;

public class SuperSaver extends Applet 
{
    TextField inputField;
    Button saveButton;
    Button clearButton;
    Label titleLabel;

    public void init() 
    {
        setLayout(null);
        
        titleLabel = new Label("Super saver");
        titleLabel.reshape(260,20,80,30);
        add(titleLabel);        
        
        inputField = new TextField();
        inputField.reshape(100,60,400,100);
        add(inputField);
        
        saveButton = new Button("SAVE");
        saveButton.reshape(100,175,70,30);
        add(saveButton);        
        
        clearButton = new Button("CLEAR");
        clearButton.reshape(430,175,70,30);
        add(clearButton);  
        
        resize(600,300);
               
    }
    public boolean handleEvent(Event event)
    {   
        if (event.target == saveButton && event.id == Event.ACTION_EVENT) 
        {
            PrintStream outwrite = new PrintStream(new FileOutputStream("Saver.txt"));

            String xxx = inputField.getText();
            outwrite.println(xxx);
            return true;
        }
        return super.handleEvent(event);
    }
}

where must i put the throw Exception,if i haven't had the file saver.txt????

Recommended Answers

All 2 Replies

> where must i put the throw Exception,if i haven't had the file saver.txt????

If you don't have ``saver.txt'', it will automatically be created given that sufficient privileges are available.

Not sure if this what you are asking, but you'll need this at the top of the method signature

public boolean handleEvent(Event event) throws IOException {

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.