🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
1 messages
1 total messages Started by Art Cummings Fri, 30 Nov 2007 03:30
exception
#278
Author: Art Cummings
Date: Fri, 30 Nov 2007 03:30
55 lines
3020 bytes
Good evening all,

I'm taking a java class and as one of the final assignments, we've got to 
write a program that uses a gui with buttons.  We've got to use a function 
that adds records.  I've got this being handled by a button but i'm getting 
an error that I need a throws exception.  As luck would have it, the 
instructor never covered this aspect of Java but I did find an example on 
google.  The problem i'm having is understanding how to use it.  Since my 
button processes the code it seems like the exception handling needs to be 
there.  I don't know of another way to call the button other than using the 
listener, that triggers the event when the button is pressed.  At this 
point, i'm stuck.  Any insight about how to do this, is appreciated.  This 
is an introductory java class so.

The error message I get.
���StudentAddWindow.java:92: exception java.io.IOException is never thrown 
in body of corresponding try statement

private class addButtonListener implements ActionListener
{

public void actionPerformed(ActionEvent e)


{

try
{ String name;
} catch (IOException x)

{

FileWriter swriter = new FileWriter("c:\\studname.txt",true);
JOptionPane.showMessageDialog(null,"The file could not be written.");
//name = StudentTextField.getText();
FileWriter swriter = new FileWriter("c:\\studname.txt",true);
//FileWriter gwriter = new FileWriter("c:\\grades.txt",true);
PrintWriter outputFile2 = new PrintWriter(gwriter);
//PrintWriter outputFile= new PrintWriter(swriter);
outputFile.println(name);
//outputFile2.println("0,0,0");
outputFile.close();
//outputFile2.close();
StudentTextField.setText("");


}





Thanks

Art 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads