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.
When selecting the maximum property for a JInternalFrame the generated source code places the setMaximum in the wrong location. The setMaximum call should be after the JInternalFrame is added the JDesktopPane. When setMaximum is called the JDK attempts to lookup the size of the JInternalFrame's parent. Since the JInternalFrame has not yet been added to the JDesktopPane no parent exists and therefore it throws a NullPointerException. Steps to reproduce: NOTE: It is expected that a General > Java Application has been created. 1) Right click "Source Packages" and select "New > JFrame Form" 2) Type MasterJFrame in the "Class Name" field 3) Click "Finish" 4) Right click Frame in Form editor and select "Set Layout > BorderLayout" 5) From the Palette, select JDesktopPane and add it to the MasterJFrame. 6) From the Palette, select JInternalFrame and add it to the JDesktopPane that you created in step 5. 7) Select the JInternalFrame you just added and from the "JInternalFrame > Properties" dialog select the maximum property. 8) From the Projects dialog right click the MasterJFrame.java file and select "Run File" 9) You will receive the Exception in FIGURE 1. 10) Select the MasterJFrame.java tab in the editor and click the "Source" button. You will see the code in FIGURE 2. 11) Notice that the setMaximum is being called before the JInternalFrame is added to the JDesktopPane. FIGURE 1 ======================================= Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.DefaultDesktopManager.maximizeFrame(DefaultDesktopManager.java:96) at javax.swing.plaf.basic.BasicInternalFrameUI.maximizeFrame(BasicInternalFrameUI.java:521) at javax.swing.plaf.basic.BasicInternalFrameUI$Handler.propertyChange(BasicInternalFrameUI.java:1569) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270) at java.awt.Component.firePropertyChange(Component.java:7159) at javax.swing.JInternalFrame.setMaximum(JInternalFrame.java:959) at MasterJFrame.initComponents(MasterJFrame.java:30) at MasterJFrame.<init>(MasterJFrame.java:15) at MasterJFrame$1.run(MasterJFrame.java:59) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:461) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) FIGURE 2 ======================================= /* * MasterJFrame.java * * Created on October 15, 2006, 6:32 PM */ /** * * @author bgoodin */ public class MasterJFrame extends javax.swing.JFrame { /** Creates new form MasterJFrame */ public MasterJFrame() { initComponents(); } /** 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() { jDesktopPane1 = new javax.swing.JDesktopPane(); jInternalFrame1 = new javax.swing.JInternalFrame(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); try { jInternalFrame1.setMaximum(true); } catch (java.beans.PropertyVetoException e1) { e1.printStackTrace(); } jInternalFrame1.setVisible(true); org.jdesktop.layout.GroupLayout jInternalFrame1Layout = new org.jdesktop.layout.GroupLayout(jInternalFrame1.getContentPane()); jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); jInternalFrame1Layout.setHorizontalGroup( jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 394, Short.MAX_VALUE) ); jInternalFrame1Layout.setVerticalGroup( jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 274, Short.MAX_VALUE) ); jInternalFrame1.setBounds(160, 120, 24, 26); jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER); getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER); pack(); }// </editor-fold> /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MasterJFrame().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JDesktopPane jDesktopPane1; private javax.swing.JInternalFrame jInternalFrame1; // End of variables declaration }
Thank you for a well-structured and precise bug report. It is a duplicate of issue 82958 that was already fixed in development builds of NetBeans 6.0. If you don't want to use development builds, you can put the corresponding code e.g. try { jInternalFrame1.setMaximum(true); } catch (java.beans.PropertyVetoException e1) { e1.printStackTrace(); } at the end of your constructor (behind the invocation of initComponents() method). *** This issue has been marked as a duplicate of 82958 ***