
terence_j_coffey1.552492488659938E12 asked a question.
Integration of NetBeans Swing generated code with Custom Control Panel
Hi , Can you assist me with the following issue. I've designed a screen in NetBeans 6.7.1 and copied the generated code into my applications. I've followed the guidelines as described at http://www.flexerasoftware.com/WEBDOCUMENTS/PDF/IA_CREATE_CUST_CODE_PANEL_NETBNS.PDF My issue is that i'm getting a syntax error at getContentPanel() in the code i've copied. The syntax error is "The method getContentPanel() is undefined for the type "My Class Name". javax.swing.GroupLayout layout=new javax.swing.groupLayout(getContentPanel()); getContentPanel().setLayout(layout); The reason for this is that my class name extends CustomControlPanel instead of the original javax.swing.JFrame parent class. getContentPanel() is defined for JFrame. What do I need to do to resolve this syntax error ? I know it's Swing related. The code snippets are as follows. I'm unable to add an attachment so I'll paste it here instead. I'll separate the file contents using === 1st file === etc Thanks in advance for your help. ====================== 1 st file Net Beans generated code ====================== /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * EM_JFrame.java * * Created on 19-Oct-2012, 12:26:36 */ package em_installer_gui; //import com.zerog.ia.api.pub.*; /** * * @author coffeyt */ public class EM_JFrame extends javax.swing.JFrame { //public class EM_JFrame extends CustomCodePanel { /** Creates new form EM_JFrame */ public EM_JFrame() { 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. */ @SuppressWarnings("unchecked") // private void initComponents() { jPanel1 = new javax.swing.JPanel(); experienceManagerCB = new javax.swing.JCheckBox(); jLabel1 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); contextStoreCB = new javax.swing.JCheckBox(); oracleCB = new javax.swing.JCheckBox(); CSDescLabel = new javax.swing.JLabel(); OracleDescLabel = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("")); setEMInstalled(true); experienceManagerCB.setSelected(true); experienceManagerCB.setText("Experience Manager"); experienceManagerCB.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { experienceManagerCBActionPerformed(evt); } }); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel1.setText("Install all components related to Experience Manager platform and core.\nIt will also install third party products and services need by the solution."); jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP); jLabel1.setAutoscrolls(true); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(experienceManagerCB) .addGap(18, 18, 18) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 377, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(326, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(experienceManagerCB) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Optional Selections")); setCSInstalled(false); contextStoreCB.setText("Context Store"); contextStoreCB.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { contextStoreCBActionPerformed(evt); } }); setOracleInstalled(false); oracleCB.setText("Oracle 9i"); oracleCB.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { oracleCBActionPerformed(evt); } }); CSDescLabel.setText("Install Context Store Feature on this machine."); OracleDescLabel.setText("Install Oracle on this machine."); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(30, 30, 30) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(contextStoreCB, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(oracleCB)) .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(CSDescLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(OracleDescLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)) .addContainerGap(474, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(21, 21, 21) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(contextStoreCB) .addComponent(CSDescLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(oracleCB) .addComponent(OracleDescLabel)) .addContainerGap(89, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Please use getContentPane() which Returns the Container object for this frame.
The solution is to remove getContentsPanel() and to replace it with "this".
you also need to remove two lines.
1) setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
2) Pack
This now allows my screen to display as a panel in InstallAnywhere.