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 23675 - initComponents() enhancement: use getter Methods for instanciating
Summary: initComponents() enhancement: use getter Methods for instanciating
Status: NEW
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P3 blocker with 3 votes (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks: 23070
  Show dependency tree
 
Reported: 2002-05-17 12:21 UTC by bauchladen
Modified: 2008-04-28 15:52 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bauchladen 2002-05-17 12:21:11 UTC
Hello, and here is my suggestion:

Netbeans uses the initComponents-Method to init
all the designed Components:
Im shure all of you know that...

//----------------------------------------------
applicationConstructor{
init_components();
..
}

// Dont touch this...
initComponents(){
   myBean    bean = new myBean();

}

private myBean bean; // property generated by Netbeans
//----------------------------------------------

But I prefer the following designpattern to
accomplish that:


private getMyBean(){
  if(bean==null){
     bean = new myBean();
     // Do lot of additional initial stuff
     // reachable by a Code-Generation Entry.
     bean.setImportantProperty(getStuff());
  }
  return bean;
}


Initcomponents Method should now look like that:

init_components(){

   myBean  bean = getMyBean(); // old Look
   getMyBean(); // new Look

   // better is direct use:
   getContentPane().add(getMyBean(),...);

}


The enhancement is crystal clear:

Whenever i get my Bean with the getter Method, i
earn a instance of it.

This becomes important when you have a lot of
stuff with dependencies (so i have very often).

I would love Netbeans more, when it would create
Methods like above described.
(I know i could do all this by hand but, my
Fingers are wound of typing such stuff.

Your judgement please, would this also be helpfull
for you ????


carsten
Comment 1 Tomas Pavek 2002-05-20 18:03:15 UTC
This could be nice. Some comments:

The getters probably should not be created for all 
components automatically - this could be configurable (for 
all in Options, and for individuals - similarly to how 
e.g. variables modifiers can be specified).

There's a problem with guarded code. We'd need the get 
method to be guarded (all code which is to be regenerated 
must be guarded) with exception of some code in the middle 
left for the user modification. But I'm affraid this is 
not possible to achieve now with current guarded sections  
in NetBeans (whole method can be guarded, or just the 
method boundaries, but not an arbitrary number of lines 
from the beginning or end of the method).

Comment 2 Marek Grummich 2002-07-22 10:00:15 UTC
Set target milestone to TBD
Comment 3 Marek Grummich 2002-07-22 10:06:31 UTC
Set target milestone to TBD
Comment 4 bruckner 2004-10-08 09:27:55 UTC
This is actually the only thing from Eclipse's VE that I liked more
than NetBeans. It's very useful from a refactoring point of view to
have separate methods returning configured graphic components; a
single, huge initComponents() does not lend itself to much fancy
manipulations.

I believe an initial implementation of fully guarded methods is the
right step: customized code would be inserted via the Code section of
the Properties window for each component.

Thank you for your attention.
Comment 5 Tomas Pavek 2005-05-10 08:40:23 UTC
See also issue 37680.