Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Exception Error

Thread view: 
KDawg44 - 04 Jun 2007 15:10 GMT
Hi,

I am receiving an error when I am compiling my main gui class for a
BattleShip game I am writing for my grad class.

I get this error:

Compiling 1 source file to /root/school/CS654/JavaClasses/Battleship/
build/classes
/root/school/CS654/JavaClasses/Battleship/src/MainGUI.java:2682:
unreported exception java.lang.Exception; must be caught or declared
to be thrown
               btnP2x2ActionPerformed(evt);}

on this line:

       btnP2x2.addActionListener(new java.awt.event.ActionListener()
{
           public void actionPerformed(java.awt.event.ActionEvent
evt) {
               btnP2x2ActionPerformed(evt);}
       });

The highlighted portion is the evt in  btnP2x2ActionPerformed(evt);}

and here is the  btnP2x2ActionPerformed() method it is calling.

   private void btnP2x2ActionPerformed(java.awt.event.ActionEvent
evt) throws Exception  {
       PlaceShip(2,2, btnP2x2);
   }

private void PlaceShip(int x, int y, javax.swing.JButton btn) throws
Exception {
            METHOD CONTENTS

Thanks for any and all help.
Andrew Thompson - 04 Jun 2007 16:00 GMT
...
>I am receiving an error when I am compiling my main gui class for a
>BattleShip game I am writing for my grad class.
>
>I get this error:
...
>Thanks for any and all help.

Suggestions..
- Use common Java nomenclature for class, method and
attribute names.  Other people trying to help (as well as other
developers looking at the code later) will be able to understand it
more easily.  Notable amongst the code was the use of method
names that start with InitialUpperCase.
- Don't forget to ask a question.
- Tune in to the forum for beginners, available as
comp.lang.java.help ..or the forum that specialises in GUI's
comp.lang.java.gui (but this is more a c.l.j.help question)
- Do more apps. from the command line till you have the
hang of things like exception handling.
- Investigate try/catch.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

KDawg44 - 04 Jun 2007 16:44 GMT
> ..
>
[quoted text clipped - 23 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200706/1

Thanks for the suggestions.  I was trying to throw the exception for a
method that was inherited from the Swing class and it didnt want me
throwing them so I had to encapsulate the code in a try-catch block.

Thanks.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.