This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 116989 - Cannot specify custom exception handling behavior for components/beans
Summary: Cannot specify custom exception handling behavior for components/beans
Status: NEW
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 5 votes (vote)
Assignee: issues@guibuilder
: 157573 173369 (view as bug list)
Depends on:
Reported: 2007-09-27 22:45 UTC by jschek
Modified: 2015-09-28 01:04 UTC (History)
3 users (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description jschek 2007-09-27 22:45:37 UTC
In the GUI/Form Editor, there is no easy way to specify a custom exception behavior for a component that throws 
exceptions on bean getter/setter methods. Currently, the editor will generate a try/catch whose behavior is to print 
the exception and move on. This may result in the form initialization to leave the component in an invalid or 
unexpected state.

While the libraries that have this behavior are rare, this has a major impact on the usability of the GUI editor when 
working with those GUI libraries. It is common when using a GUI library that involves the use of JNI, J-Integra, or 
sockets. The problem is severe enough to warrant going back to hand-coded SWING initialization.

This is the code that is currently generated by the GUI editor:

   private void initComponents() {
        esriMapBean = new;
   //... this block is the exception handling provided by Netbeans
        try {
        } catch ( e1) {
            e1.printStackTrace(); //I really need to pass this IOException back up or wrap it in a RuntimeException
   //... if this fails, it can leave my form in a bad state...

Currently, the only work-around is to add the component and ignore the properties editor. Then use the Post-Init Code 
property to set these properties by hand.

Not sure what the permanent solution should be. A stop-gap solution could be to add a "Default Exception Handler" for 
the component initialization. If defined, all exception would get passed to the handler where I could specify my own 
code. If not specified, then continue with the existing behavior.

Something like this:

This would be more desirable:
   private MyPanel() {
      try {
      } catch(InvocationTargetExceptione) {
         //my default handler code goes here

   private void initComponents() throws InvocationTargetException{
        esriMapBean = new;
        try {
        } catch ( e1) {
            //maybe a different exception--desirable to have the Bean and the property
            throw new InvocationTargetException(e1,"esriMapBean.keyIntercept"); //i.e. wrap exception +
Comment 1 Tomas Pavek 2009-01-29 18:02:49 UTC
*** Issue 157573 has been marked as a duplicate of this issue. ***
Comment 2 Michel Graciano 2009-02-02 17:40:03 UTC
Any chance to see it for 7.0?
Comment 3 Tomas Pavek 2009-09-30 15:14:28 UTC
*** Issue 173369 has been marked as a duplicate of this issue. ***
Comment 4 kalle1 2015-09-28 01:04:08 UTC
A workaround seems to add a `throws` statement to `initComponents` by opening it in an external editor.