0
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????

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by dickersonka
0

> 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.

0

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 {

}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.