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 199384

Summary: Stack overflow error with ClonableTopComponent
Product: apisupport Reporter: ramesh_vangala
Component: ProjectAssignee: Jesse Glick <jglick>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P2    
Version: 7.0   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Attachments: Stack trace

Description ramesh_vangala 2011-06-13 18:17:13 UTC
Created attachment 108879 [details]
Stack trace

Our class extends ClonableTopComponent, we overridden getVisualRepresentation(). In that method we are just removing all components and adding again. Please see code below:
public JComponent getVisualRepresentation() {

      if( haveXmlErrors ) {
         jpanel.removeAll();
         jpanel.setLayout( new BorderLayout() );
         jpanel.add( errorUi, BorderLayout.CENTER );
         return jpanel;
      }
      jpanel.removeAll();
      jpanel.setLayout( new BorderLayout() );
      jpanel.add( ( JComponent )ui, BorderLayout.CENTER );
      return jpanel;
   }
It is causing stack overflow error. Please find attached stack trace.
Comment 1 Stanislav Aubrecht 2011-06-14 14:56:53 UTC
you must move the jpanel modifications out of the getVisualRepresentation() method. that method should just return the jpanel instance without any other changes to component hierarchy. multiview window has a custom focus traversal policy which calls this method frequently. changes in component hierarchy fire changes in focus manager which asks for visual representation component which leads to stack overflow.

the best place to change multiview content are MultiViewElement.componentOpened() and MultiViewElement.componentShowing() methods.
Comment 2 ramesh_vangala 2011-06-21 11:53:59 UTC
Thanks Issue fixed, Thanks alot.