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 2196

Summary: Automatically suggest import statements for new classes if they are not already there. (Dynamic code completion type of thing).
Product: editor Reporter: Jon Koplin <jkoplin>
Component: Completion & TemplatesAssignee: issues@editor <issues>
Severity: enhancement CC: sdedic
Priority: P4    
Version: 3.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description Jon Koplin 1999-06-10 19:12:35 UTC
this is a new suggestion for the editor. When I use some Java standard
classes (and other), sometimes I`ve got difficulties to remember the name of
the Java package I have to import. It would be nice if the editor could
propose to me the missing import statements to be added to my java file.

public class Main
  public void main( String  [] args )
    JFrame f = new JFrame( "sample JFrame" );

    f.setBounds( 10, 10, 100, 100 );
    f.setVisible( true );

    f.addWindowListener( new WindowAdatper()

      public void windowClosing( WindowEvent e ) { System.exit( 0 ); }
    } );

By pressing the F1 key (for example), the editor would propose me to add the
following statements:

  import javax.swing.*;
  import java.awt.event.*;


  import javax.swing.JFrame;
  import java.awt.event.WindowEvent;
  import java.awt.event.WindowAdapter;

If the import is already there, then it is no longer proposed.
Comment 1 Jan Lahoda 2001-01-24 15:38:59 UTC
Only changed version to Development.
Comment 2 Jan Chalupa 2001-05-05 21:56:20 UTC
Target milestone -> 3.3
Comment 3 David Konecny 2001-05-22 15:34:18 UTC
Re-assigning issues back to the
Comment 4 David Konecny 2001-05-22 15:50:16 UTC
Changing the state of the issue to ASSIGNED, because it was cover in 
Requirements document at
Comment 5 Johan Walles 2001-06-26 08:16:45 UTC
Having this triggering on saving your file would be nice.  It could work like this:
* You save the file
* NetBeans tries to compile it
* NetBeans shows you a list of all errors with suggestions for fixing trivial ones

"Trivial" errors would be classes in packages that haven't been imported plus
anything else that might be easy / possible to fix programmatically.
Comment 6 Jan Chalupa 2001-11-27 12:28:00 UTC
Target milestone -> 3.3.1.
Comment 7 Svata Dedic 2001-12-05 10:05:55 UTC
Is there any support / infrastructure needed from us (== java) ?
Comment 8 Marek Grummich 2002-07-22 09:47:35 UTC
Set target milestone to TBD
Comment 9 Marek Grummich 2002-07-22 09:50:46 UTC
Set target milestone to TBD
Comment 10 derisor 2003-02-10 10:56:25 UTC
Actually I think we could "borrow" a feature from Eclipse. 
In that program, when the user uses the code complettion, 
the import is automatically added to the file. So if I 
type "JColorChooser" and then hit ctrl-space, the color 
chooser import would be added to the file. This would make 
things allot more convenient. 
Comment 11 vladmihaisima 2003-09-28 10:25:17 UTC
*** Issue 35587 has been marked as a duplicate of this issue. ***
Comment 12 psuk 2004-03-23 19:15:14 UTC
Changing subcomponent to "code completion"

Comment 13 _ gtzabari 2004-09-10 18:38:26 UTC

*** This issue has been marked as a duplicate of 47399 ***