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.
The GUI Builder should remove imports that are not used in the java.awt and javax.swing packages and subpackages.
--For instance: --Before: import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.SwingUtilities; public class Main extends JFrame { /** Creates new form Main */ public Main() { initComponents(); setVisible(true); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jScrollPane1 = new JScrollPane(); jTextArea1 = new JTextArea(); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1); getContentPane().add(jScrollPane1, BorderLayout.CENTER); }// </editor-fold> /** * @param args the command line arguments */ public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { new Main(); } }); } // Variables declaration - do not modify private JScrollPane jScrollPane1; private JTextArea jTextArea1; // End of variables declaration } --After: import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.SwingUtilities; public class Main extends JFrame { /** Creates new form Main */ public Main() { initComponents(); setVisible(true); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); }// </editor-fold> /** * @param args the command line arguments */ public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { new Main(); } }); } // Variables declaration - do not modify // End of variables declaration } --Unused imports should be removed: ----java.awt.BorderLayout ----import javax.swing.JScrollPane ----import javax.swing.JTextArea
Thank you for your report. Maybe it will be possible to remove automatically unused import of xyz component, while removing that component. Also we could automatically remove unused beansbinding imports if its possible.
*** Bug 124244 has been marked as a duplicate of this bug. ***
Trying to "fix imports" might have sense when "Generate Full Classnames" option is off, in which case the GUI builder adds imports -- so could also remove them.
*** Bug 231161 has been marked as a duplicate of this bug. ***