🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #278

exception

#278
From: 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 
Technical Details
Message-ID: <HbWdnTAn4IHCHtLanZ2dnUVZ_gGdnZ2d@comcast.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,3306154f1d572a27,start
X-Google-Attributes: gid111d45,public,usenet
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 29 Nov 2007 21:28:31 -0600
From: "Art Cummings" <aikiart7@gmail.com>
Newsgroups: borland.public.jbuilder.java.swing
Subject: exception
Date: Thu, 29 Nov 2007 22:30:16 -0500
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
Message-ID: <HbWdnTAn4IHCHtLanZ2dnUVZ_gGdnZ2d@comcast.com>
Lines: 57
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 24.98.253.225
X-Trace: sv3-oXOzYuUucFjGfU05TMfr+oWuqBan46Q4F2fecuj4/giZ+hGi29OeED5zyXOdPVeW+MOe1GsFze6ULLA!LYDnTT/Xb6w9CCRM6aoDEsM3tjyDreWgE1g3PY+oNcn58eozPZXV8YK4jBSkEC91A/ri4drCqmhl!DNK86KoyPUjHebBLLxu1mOE/jriyhQ==
X-Complaints-To: abuse@comcast.net
X-DMCA-Complaints-To: dmca@comcast.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.36