Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2836

exception error

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Art Cummings" <art.cummings@THRWHITE.remove-dii-this>
Subject exception error
Message-ID <3omdnc09V7LaHtLanZ2dnUVZ_hCdnZ2d@comcast.com> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 61
Date Wed, 27 Apr 2011 15:41:25 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918885 96.60.20.240 (Wed, 27 Apr 2011 10:41:25 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:41:25 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:2836

Show key headers only | View raw


  To: comp.lang.java.gui
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.
+o-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

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar | Unroll thread


Thread

exception error "Art Cummings" <art.cummings@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000
  Re: exception error "Nigel Wade" <nigel.wade@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000

csiph-web