cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
coffey_t
Level 2

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)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(44, 44, 44)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();
}//

protected boolean EMInstalled = true;

/**
* Get the value of EMInstalled
*
* @return the value of EMInstalled
*/
public boolean isEMInstalled() {
return EMInstalled;
}

/**
* Set the value of EMInstalled
*
* @param EMInstalled new value of EMInstalled
*/
public void setEMInstalled(boolean EMInstalled) {
this.EMInstalled = EMInstalled;
}
protected boolean CSInstalled;

/**
* Get the value of CSInstalled
*
* @return the value of CSInstalled
*/
public boolean isCSInstalled() {
return CSInstalled;
}

/**
* Set the value of CSInstalled
*
* @param CSInstalled new value of CSInstalled
*/
public void setCSInstalled(boolean CSInstalled) {
this.CSInstalled = CSInstalled;
}
protected boolean OracleInstalled = false;

/**
* Get the value of OracleInstalled
*
* @return the value of OracleInstalled
*/
public boolean isOracleInstalled() {
return OracleInstalled;
}

/**
* Set the value of OracleInstalled
*
* @param OracleInstalled new value of OracleInstalled
*/
public void setOracleInstalled(boolean OracleInstalled) {
this.OracleInstalled = OracleInstalled;
}



private void contextStoreCBActionPerformed(java.awt.event.ActionEvent evt) {
if ( contextStoreCB.isEnabled()) {
contextStoreCB.setEnabled(false);
setCSInstalled(false);
} else {
contextStoreCB.setEnabled(true);
setCSInstalled(true);
}
}

private void oracleCBActionPerformed(java.awt.event.ActionEvent evt) {
if ( oracleCB.isEnabled()) {
oracleCB.setEnabled(false);
setOracleInstalled(false);
} else {
oracleCB.setEnabled(true);
setOracleInstalled(true);
}
}

private void experienceManagerCBActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new EM_JFrame().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JLabel CSDescLabel;
private javax.swing.JLabel OracleDescLabel;
private javax.swing.JCheckBox contextStoreCB;
private javax.swing.JCheckBox experienceManagerCB;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JCheckBox oracleCB;
// End of variables declaration

}



=================== 2nd file my attempt to utilise ===================





import java.awt.Container;

import javax.swing.GroupLayout;

import com.zerog.ia.api.pub.CustomCodePanel;
import com.zerog.ia.api.pub.CustomCodePanelProxy;

@SuppressWarnings("serial")
//public class SelectFeatures extends CustomCodePanel
//{
// @Override
// public boolean setupUI(CustomCodePanelProxy custPanel) {
// // TODO Auto-generated method stub
// this.setLayout(new BorderLayout());
// this.add(new JLabel("THIS IS CUSTOM PANEL 3"), BorderLayout.CENTER);
//
//
// return true;
// }
//}
public class SelectFeatures extends CustomCodePanel
{
private boolean isSetup = false;
private CustomCodePanelProxy ccPP;

@Override
// public boolean setupUI(CustomCodePanelProxy custPanel) {
// this.setLayout(new BorderLayout());
// this.add(new EM_JFrame(), BorderLayout.CENTER);
// return true;
// }
public boolean setupUI(CustomCodePanelProxy customCodePanelProxy) {
if(isSetup) {
removeAll();
}
//Container panel;
//this.setLayout(new BorderLayout());
//this.add(new SelectFeatures(), BorderLayout.CENTER);
//GroupLayout layout = new GroupLayout(panel);
// panel.setLayout(layout);
ccPP = customCodePanelProxy;
initComponents();
isSetup = true;
return true;
}

//@Override
public boolean okToContinue() {
//ccpp.setVariable("USER_INSTALL_DRIVE$",(String)jComboBox1.getSelectedItem());
ccPP.setVariable("INSTALL_EM$", (isEMInstalled() ? "true":"false"));
ccPP.setVariable("INSTALL_CS$", (isCSInstalled() ? "true":"false"));
ccPP.setVariable("INSTALL_ORACLE$", (isOracleInstalled() ? "true":"false"));
return true;
}

public String getTitle() {
return "getTitle() has returned.";
}

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)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(44, 44, 44)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();
}//
protected boolean EMInstalled = true;

/**
* Get the value of EMInstalled
*
* @return the value of EMInstalled
*/
public boolean isEMInstalled() {
return EMInstalled;
}

/**
* Set the value of EMInstalled
*
* @param EMInstalled new value of EMInstalled
*/
public void setEMInstalled(boolean EMInstalled) {
this.EMInstalled = EMInstalled;
}
protected boolean CSInstalled;

/**
* Get the value of CSInstalled
*
* @return the value of CSInstalled
*/
public boolean isCSInstalled() {
return CSInstalled;
}

/**
* Set the value of CSInstalled
*
* @param CSInstalled new value of CSInstalled
*/
public void setCSInstalled(boolean CSInstalled) {
this.CSInstalled = CSInstalled;
}
protected boolean OracleInstalled = false;

/**
* Get the value of OracleInstalled
*
* @return the value of OracleInstalled
*/
public boolean isOracleInstalled() {
return OracleInstalled;
}

/**
* Set the value of OracleInstalled
*
* @param OracleInstalled new value of OracleInstalled
*/
public void setOracleInstalled(boolean OracleInstalled) {
this.OracleInstalled = OracleInstalled;
}



private void contextStoreCBActionPerformed(java.awt.event.ActionEvent evt) {
if ( contextStoreCB.isEnabled()) {
contextStoreCB.setEnabled(false);
setCSInstalled(false);
} else {
contextStoreCB.setEnabled(true);
setCSInstalled(true);
}
}

private void oracleCBActionPerformed(java.awt.event.ActionEvent evt) {
if ( oracleCB.isEnabled()) {
oracleCB.setEnabled(false);
setOracleInstalled(false);
} else {
oracleCB.setEnabled(true);
setOracleInstalled(true);
}
}

private void experienceManagerCBActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new EM_JFrame().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JLabel CSDescLabel;
private javax.swing.JLabel OracleDescLabel;
private javax.swing.JCheckBox contextStoreCB;
private javax.swing.JCheckBox experienceManagerCB;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JCheckBox oracleCB;
}
Labels (1)
0 Kudos
(2) Replies
gshamrao
Level 3

Hi,

Please use getContentPane() which Returns the Container object for this frame.
0 Kudos
coffey_t
Level 2

thanks for your post.

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.
0 Kudos