0

I'm open to using a simple FileDialog option for both print and save but I'm stuck on the proper syntax for an applet. It is the use of JApplet's Container versus a JFrame in an application. The applet has to appear within the html page.

Any help would be much appreciated.

My code for the save button activation is as follows:

ActionListener buttonHandlerS = new ActionListener() {
public void actionPerformed(ActionEvent e) {
textArea.getText();
FileWriter writer = null;
try {
textArea.getText();
writer = new FileWriter("c://matrix_small_projects.txt");
textArea.write(writer);
} 

catch (IOException exception) {
System.err.println("Save not successful");
exception.printStackTrace();
} 

finally {
if (writer != null) 
{
try{
writer.close();
} 
catch (IOException exception) {
System.err.println("Error closing writer");
exception.printStackTrace();
}
}
}
saveContent.addActionListener(buttonHandlerS);
};
};

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by masijade
0

What does the API docs say about what getText() returns (and whether or not there is even a write() method in JTextArea). And how do the tutorials show about using a FileWriter?

Come on man. You can at least make a real attempt. You can't just make stuff up as you go along, you know?

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.