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.

9 Years
Discussion Span
Last Post by gokcer

Two ways: throw or catch.
Catch this Exception :

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        try {
        } 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.