0

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

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.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by gokcer
0

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(...
        }       
    }
Attachments catch.gif 13.64 KB
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.