943,788 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 496
  • Java RSS
Jan 23rd, 2009
0

Java Exception Problem (Please Help!)

Expand Post »
I am doing a Java project and in my gui I want to use Buttons. I want to put a class' internal parts code as a button action. Because the class Throws Exception when I copy the contents of the class under the button definition I encounter unreported exception error. Since I cannot edit the
Java Syntax (Toggle Plain Text)
  1. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
part I cannot make the button throw an exception so my question is whether I can modify this button definition which is automatically generated by NetBeans to include this "throws exception" statement. Any help will be much appreciated as I have to get over this to go on. Thanks in advance.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gokcer is offline Offline
2 posts
since Jan 2009
Jan 23rd, 2009
0

Re: Java Exception Problem (Please Help!)

Two ways: throw or catch.
Catch this Exception :
       private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        try {
            myButton1ActionPerformed(evt);
        } catch (Exception ex) {
            //Logger.getLogger(NewJPanel.class.getName()).log(Level.SEVERE, null, ex);
            ex.printStackTrace();// or other message JOptionPane.showMessageDialog(...
        }       
    }
Attached Thumbnails
Click image for larger version

Name:	catch.gif
Views:	9
Size:	13.6 KB
ID:	8962  
Reputation Points: 123
Solved Threads: 106
Posting Pro
quuba is offline Offline
573 posts
since Nov 2008
Jan 24th, 2009
0

Re: Java Exception Problem (Please Help!)

Tank you very much it worked!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gokcer is offline Offline
2 posts
since Jan 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: NetBeans Err : "The File Formate is Not Recognized"
Next Thread in Java Forum Timeline: How to color grayscale (& taransparent) image in java?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC