Exception Error

K

KDawg44

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.
 
A

Andrew Thompson

KDawg44 wrote:
...
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.

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200706/1
 
K

KDawg44

KDawg44 wrote:

..



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.


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top