Code:
public class CreateOffenderFormPg1 extends AbstractForm
{
public static final String PAGE_ONE = "pageOne";
private IdentificationSupport identificationSupport;
private SimpleDateFormat simpleDateFormat;
private JFormattedTextField iincarcerationNumber;
private JTextField iinmateId;
private JTextField ifirstName;
private JTextField iminit;
private JTextField ilastName;
private JFormattedTextField idob;
private JComboBox isexPvv;
private JComboBox iclassCodePvv;
private JComboBox iracePvv;
private JComboBox isecurityIdPvv;
private JComboBox istatusPvv;
private JFormattedTextField issno;
private JComboBox iadmissionTypePvv;
private JComboBox ictechnicalViolation;
private JTextField ihealthAlert;
private JComboBox idetainers1Pvv;
private JComboBox idetainers2Pvv;
private JComboBox idetainers3Pvv;
private JComboBox idetainers4Pvv;
private JComboBox idetainers5Pvv;
private JTextField isrg;
private JTextField iarea;
private JTextField isuffix;
private JTextField icellId;
private JTextField ipinNo;
private JTextField ijobCode;
private JFormattedTextField istatusDate;
private JTextField ipcReason;
private JCheckBox ipcIndicatorBool;
private JComboBox inonstInmateTypePvv;
private JTextField ibciNumber;
private JFormattedTextField icommConfEligDate;
private JTextField isosLocation;
private JTextField ifpNbr;
private JFormattedTextField ifpClass1;
private JTextField ifpNbr2;
private JFormattedTextField ifpClass2;
private JTextField ifbi;
private JComboBox isosCodePvv;
private JComboBox isosStatePvv;
/** Creates a new instance of CreateOffender */
public CreateOffenderFormPg1(FormModel formModel)
{
super(formModel, PAGE_ONE);
}
private void initComponents()
{
identificationSupport = (IdentificationSupport)this.getFormObject();
simpleDateFormat = new SimpleDateFormat(getMessage("simpleDateFormat"));
iincarcerationNumber = new JFormattedTextField(new DecimalFormat("#"));
//iinmateId = new JFormattedTextField(new DecimalFormat("0000000"));
ifirstName = new JTextField();
iminit = new JTextField();
ilastName = new JTextField();
idob = new JFormattedTextField();
issno = new JFormattedTextField(new DecimalFormat("000000000"));
ihealthAlert = new JTextField();
isrg = new JTextField();
iarea = new JTextField();
isuffix = new JTextField();
icellId = new JTextField();
ipinNo = new JTextField();
ijobCode = new JTextField();
istatusDate = new JFormattedTextField();
ipcReason = new JTextField();
ipcIndicatorBool = new JCheckBox();
ibciNumber = new JTextField();
icommConfEligDate = new JFormattedTextField(simpleDateFormat);
isosLocation = new JTextField();
ifpNbr = new JTextField();
ifpClass1 = new JFormattedTextField(new DecimalFormat("#"));
ifpNbr2 = new JTextField();
ifpClass2 = new JFormattedTextField(new DecimalFormat("#"));
ifbi = new JTextField();
}
/**
* Adds fill components to empty cells in the first row and first column of
* the grid. This ensures that the grid spacing will be the same as shown in
* the designer.
* @param cols an array of column indices in the first row where fill
* components should be added.
* @param rows an array of row indices in the first column where fill
* components should be added.
*/
private void addFillComponents( Container panel, int[] cols, int[] rows )
{
Dimension filler = new Dimension(10,10);
boolean filled_cell_11 = false;
CellConstraints cc = new CellConstraints();
if ( cols.length > 0 && rows.length > 0 )
{
if ( cols[0] == 1 && rows[0] == 1 )
{
/** add a rigid area */
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
filled_cell_11 = true;
}
}
for( int index = 0; index < cols.length; index++ )
{
if ( cols[index] == 1 && filled_cell_11 )
{
continue;
}
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
}
for( int index = 0; index < rows.length; index++ )
{
if ( rows[index] == 1 && filled_cell_11 )
{
continue;
}
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
}
}
public JComponent buildScreen()
{
initComponents();
JPanel jpanel1 = new JPanel();
JScrollPane detailScrollPane = new JScrollPane();
CellConstraints cc = new CellConstraints();
////////////////////////////////////////////////////////////////////////
//
// Create and set the layout
//
////////////////////////////////////////////////////////////////////////
FormLayout formlayout1 = new FormLayout(
/* Column Def */
"FILL:4DLU:NONE,FILL:85PX:NONE,FILL:4DLU:NONE,"+
"FILL:70DLU:NONE,FILL:4DLU:NONE,"+
"FILL:73PX:NONE,FILL:4DLU:NONE,"+
"FILL:MIN(130PX;DEFAULT):GROW(1.0),FILL:4DLU:NONE,"+
"FILL:80PX:NONE,FILL:4DLU:NONE,"+
"FILL:75DLU:NONE,FILL:4DLU:NONE,"+
"FILL:73PX:NONE,FILL:4DLU:NONE,"+
"FILL:60DLU:NONE,FILL:4DLU:NONE",
/* Row Def */
"CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,"+
"CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,"+
"CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,"+
"CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:15DLU:NONE,"+
"CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,"+
"CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,"+
"CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,"+
"CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,"+
"CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,"+
"CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,"+
"CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,"+
"CENTER:DEFAULT:NONE,CENTER:12DLU:GROW(1.0)"
);
jpanel1.setLayout(formlayout1);
////////////////////////////////////////////////////////////////////////
//
// Bind the fields
//
////////////////////////////////////////////////////////////////////////
getFormModel().bind(iincarcerationNumber, "iincarcerationNumber");
//getFormModel().bind(iinmateId, "iinmateId");
iinmateId = getFormModel().createBoundTextField("iinmateId");
getFormModel().bind(ifirstName, "ifirstName");
getFormModel().bind(iminit, "iminit");
getFormModel().bind(ilastName, "ilastName");
getFormModel().bind(idob, "idob");
isexPvv = getFormModel()
.createBoundComboBox("isexPvv", identificationSupport.getIsexList()
.toArray());
isexPvv.setEditable(false);
iclassCodePvv = getFormModel()
.createBoundComboBox("iclassCodePvv",
identificationSupport.getIclassCodeList().toArray());
iclassCodePvv.setEditable(false);
iracePvv = getFormModel()
.createBoundComboBox("iracePvv",
identificationSupport.getIraceList().toArray());
iracePvv.setEditable(false);
isecurityIdPvv = getFormModel()
.createBoundComboBox("isecurityIdPvv",
identificationSupport.getIsecurityIdList().toArray());
isecurityIdPvv.setEditable(false);
istatusPvv = getFormModel()
.createBoundComboBox("istatusPvv",
identificationSupport.getIstatusList().toArray());
istatusPvv.setEditable(false);
getFormModel().bind(issno, "issno");
iadmissionTypePvv = getFormModel()
.createBoundComboBox("iadmissionTypePvv",
identificationSupport.getIadmissionTypeList().toArray());
iadmissionTypePvv.setEditable(false);
ictechnicalViolation = getFormModel()
.createBoundComboBox("ictechnicalViolation",
identificationSupport.getIctechnicalViolationList().toArray());
ictechnicalViolation.setEditable(false);
getFormModel().bind(ihealthAlert, "ihealthAlert");
idetainers1Pvv = getFormModel()
.createBoundComboBox("idetainers1Pvv",
identificationSupport.getIdetainersList().toArray());
idetainers1Pvv.setEditable(false);
idetainers2Pvv = getFormModel()
.createBoundComboBox("idetainers2Pvv",
identificationSupport.getIdetainersList().toArray());
idetainers2Pvv.setEditable(false);
idetainers3Pvv = getFormModel()
.createBoundComboBox("idetainers3Pvv",
identificationSupport.getIdetainersList().toArray());
idetainers3Pvv.setEditable(false);
idetainers4Pvv = getFormModel()
.createBoundComboBox("idetainers4Pvv",
identificationSupport.getIdetainersList().toArray());
idetainers4Pvv.setEditable(false);
idetainers5Pvv = getFormModel()
.createBoundComboBox("idetainers5Pvv",
identificationSupport.getIdetainersList().toArray());
idetainers5Pvv.setEditable(false);
getFormModel().bind(isrg, "isrg");
getFormModel().bind(iarea, "iarea");
getFormModel().bind(isuffix, "isuffix");
getFormModel().bind(icellId, "icellId");
getFormModel().bind(ipinNo, "ipinNo");
getFormModel().bind(ijobCode, "ijobCode"/*,
ValueCommitPolicy.FOCUS_LOST*/);
getFormModel().bind(istatusDate, "istatusDate");
getFormModel().bind(ipcReason, "ipcReason");
getFormModel().bind(ipcIndicatorBool, "ipcIndicatorBool");
inonstInmateTypePvv = getFormModel()
.createBoundComboBox("inonstInmateTypePvv",
identificationSupport.getInonstInmateTypeList().toArray());
inonstInmateTypePvv.setEditable(false);
getFormModel().bind(ibciNumber, "ibciNumber");
getFormModel().bind(icommConfEligDate, "icommConfEligDate");
getFormModel().bind(isosLocation, "isosLocation");
getFormModel().bind(ifpNbr, "ifpNbr");
getFormModel().bind(ifpClass1, "ifpClass1");
getFormModel().bind(ifpNbr2,"ifpNbr2");
getFormModel().bind(ifpClass2, "ifpClass2");
getFormModel().bind(ifbi, "ifbi");
isosCodePvv = getFormModel()
.createBoundComboBox("isosCodePvv",
identificationSupport.getIsosCodeList().toArray());
isosCodePvv.setEditable(false);
isosStatePvv = getFormModel()
.createBoundComboBox("isosStatePvv",
identificationSupport.getIsosStateList().toArray());
isosStatePvv.setEditable(false);
///////////////////////////////////////////////////////////////////////
//
// add the Fields to the layout.
//
///////////////////////////////////////////////////////////////////////
addComponentToPanel(cc.xy(4,2), jpanel1, iincarcerationNumber,
"iincarcerationNumber");
addComponentToPanel(cc.xy(4,4), jpanel1, iinmateId, "iinmateId", true);
addComponentToPanel(cc.xy(4,6), jpanel1, ifirstName, "ifirstName",
true);
addComponentToPanel(cc.xy(8,6), jpanel1, iminit, "iminit", true);
addComponentToPanel(cc.xy(12,6), jpanel1, ilastName, "ilastName", true);
addComponentToPanel(cc.xy(4,8), jpanel1, new SCTDateChooser(idob, "idob"),
"idob", true);
cc = new CellConstraints(8,8,1,1, CellConstraints.DEFAULT,
CellConstraints.CENTER);
addComponentToPanel(cc, jpanel1, isexPvv, "isexPvv", true);
cc = new CellConstraints(12,8,5,1,CellConstraints.DEFAULT,
CellConstraints.CENTER);
addComponentToPanel(cc, jpanel1, iclassCodePvv, "iclassCodePvv", true);
addComponentToPanel(cc.xy(4,10), jpanel1, iracePvv, "iracePvv", true);
addComponentToPanel(cc.xywh(12,10,5,1), jpanel1, isecurityIdPvv,
"isecurityIdPvv", true);
addComponentToPanel(cc.xywh(4,14,5,1), jpanel1, istatusPvv,
"istatusPvv", true);
addComponentToPanel(cc.xy(8,10), jpanel1, issno, "issno", true);
addComponentToPanel(cc.xywh(4,16,5,1), jpanel1, iadmissionTypePvv,
"iadmissionTypePvv", true);
addComponentToPanel(cc.xywh(12,16,5,1), jpanel1,
ictechnicalViolation, "ictechnicalViolation", true);
addComponentToPanel(cc.xywh(12,20,5,1), jpanel1, ihealthAlert,
"ihealthAlert", true);
addComponentToPanel(cc.xywh(4,22,5,1), jpanel1, idetainers1Pvv,
"idetainers1Pvv", true);
addComponentToPanel(cc.xywh(4,24,5,1), jpanel1, idetainers2Pvv,
"idetainers2Pvv", true);
addComponentToPanel(cc.xywh(4,26,5,1), jpanel1, idetainers3Pvv,
"idetainers3Pvv", true);
addComponentToPanel(cc.xywh(4,28,5,1), jpanel1, idetainers4Pvv,
"idetainers4Pvv", true);
addComponentToPanel(cc.xywh(4,30,5,1), jpanel1, idetainers5Pvv,
"idetainers5Pvv", true);
addComponentToPanel(cc.xy(8,2), jpanel1, isrg, "isrg", true);
addComponentToPanel(cc.xy(12,12), jpanel1, iarea, "iarea", true);
addComponentToPanel(cc.xy(16,6), jpanel1, isuffix, "isuffix", true);
addComponentToPanel(cc.xywh(14,12,3,1), jpanel1, icellId, "icellId",
true);
addComponentToPanel(cc.xy(8,4), jpanel1, ipinNo, "ipinNo", true);
addComponentToPanel(cc.xy(12,2), jpanel1, ijobCode, "ijobCode", true);
addComponentToPanel(cc.xy(12,14), jpanel1, new SCTDateChooser(
istatusDate, "istatusDate"), "istatusDate", true);
addComponentToPanel(cc.xywh(12,18,5,1), jpanel1, ipcReason,
"ipcReason", true);
addComponentToPanel(cc.xy(10,18), jpanel1, ipcIndicatorBool,
"ipcIndicatorBool", true);
addComponentToPanel(cc.xywh(4,18,5,1), jpanel1, inonstInmateTypePvv,
"inonstInmateTypePvv", true);
addComponentToPanel(cc.xy(12,4), jpanel1, ibciNumber, "ibciNumber",
false);
addComponentToPanel(cc.xy(16,4), jpanel1, icommConfEligDate,
"icommConfEligDate", false);
addComponentToPanel(cc.xywh(10,32,3,1), jpanel1, isosLocation,
"isosLocation", true);
addComponentToPanel(cc.xywh(14,26,3,1), jpanel1, ifpNbr, "ifpNbr",
true);
addComponentToPanel(cc.xy(12,26), jpanel1, ifpClass1, "ifpClass1",
true);
addComponentToPanel(cc.xywh(14,28,3,1), jpanel1, ifpNbr2, "ifpNbr2",
true);
addComponentToPanel(cc.xy(12,28), jpanel1, ifpClass2, "ifpClass2",
true);
addComponentToPanel(cc.xywh(12,24,5,1), jpanel1, ifbi, "ifbi", true);
addComponentToPanel(cc.xywh(4,32,3,1), jpanel1, isosCodePvv,
"isosCodePvv", true);
addComponentToPanel(cc.xywh(4,34,3,1), jpanel1, isosStatePvv,
"isosStatePvv", true);
ipcIndicatorBool.setActionCommand("P.C.");
ipcIndicatorBool.setBackground(new Color(212,208,200));
ipcIndicatorBool.setOpaque(false);
ipcIndicatorBool.setText("P.C.");
ipcIndicatorBool.setHorizontalAlignment(JCheckBox.RIGHT);
ipcIndicatorBool.setHorizontalTextPosition(JCheckBox.LEFT);
////////////////////////////////////////////////////////////////////////
//
// Labels
//
////////////////////////////////////////////////////////////////////////
addLabelToPanel(cc.xy(6,6), jpanel1, "odv.iminit");
addLabelToPanel(cc.xy(10,6), jpanel1, "odv.ilastName");
addLabelToPanel(cc.xy(6,8), jpanel1, "odv.isexPvv");
addLabelToPanel(cc.xy(10,8), jpanel1, "odv.iclassCodePvv");
addLabelToPanel(cc.xy(6,10), jpanel1, "odv.issno");
addLabelToPanel(cc.xy(10,10), jpanel1, "odv.isecurityId1");
addLabelToPanel(cc.xy(10,12), jpanel1, "odv.iAreaCell");
addLabelToPanel(cc.xy(2,2), jpanel1, "odv.iincarcerationNumber");
addLabelToPanel(cc.xy(2,4), jpanel1, "odv.iinmateId");
addLabelToPanel(cc.xy(2,6), jpanel1, "odv.ifirstName");
addLabelToPanel(cc.xy(2,8), jpanel1, "odv.idob");
addLabelToPanel(cc.xy(2,10), jpanel1, "odv.iracePvv");
addLabelToPanel(cc.xy(2,14), jpanel1, "odv.istatus1");
addLabelToPanel(cc.xy(2,16), jpanel1, "odv.iadmissionType");
addLabelToPanel(cc.xy(10,16), jpanel1, "odv.ictechnicalViolation");
addLabelToPanel(cc.xy(10,20), jpanel1, "odv.ihealthAlert");
addLabelToPanel(cc.xy(14,6), jpanel1, "odv.isuffix");
addLabelToPanel(cc.xy(2,22), jpanel1, "odv.idetainers1");
addLabelToPanel(cc.xy(2,24), jpanel1, "odv.idetainers2");
addLabelToPanel(cc.xy(2,26), jpanel1, "odv.idetainers3");
addLabelToPanel(cc.xy(2,28), jpanel1, "odv.idetainers4");
addLabelToPanel(cc.xy(2,30), jpanel1, "odv.idetainers5");
addLabelToPanel(cc.xy(6,2), jpanel1, "odv.isrg");
addLabelToPanel(cc.xy(10,2), jpanel1, "odv.ijobCode");
addLabelToPanel(cc.xy(6,4), jpanel1, "odv.ipinNo");
addLabelToPanel(cc.xy(10,4), jpanel1, "odv.ibciNumber");
addLabelToPanel(cc.xy(14,4), jpanel1, "odv.icommConfEligDate");
addLabelToPanel(cc.xy(2,18), jpanel1, "odv.inonstInmateType");
addLabelToPanel(cc.xy(10,14), jpanel1, "odv.istatusDate");
addLabelToPanel(cc.xy(2,32), jpanel1, "odv.isosCode");
addLabelToPanel(cc.xy(8,32), jpanel1, "odv.isosLocation");
addLabelToPanel(cc.xy(10,28), jpanel1, "odv.ifpClass1");
JLabel jlabel34 = new JLabel();
jlabel34.setFont(new Font("Dialog",Font.BOLD,12));
jlabel34.setText("/");
jlabel34.setHorizontalAlignment(JLabel.CENTER);
jpanel1.add(jlabel34,cc.xy(13,28));
addLabelToPanel(cc.xy(10,26), jpanel1, "odv.ifpNbr");
JLabel jlabel36 = new JLabel();
jlabel36.setFont(new Font("Dialog",Font.BOLD,12));
jlabel36.setText("/");
jlabel36.setHorizontalAlignment(JLabel.CENTER);
jpanel1.add(jlabel36,cc.xy(13,26));
addLabelToPanel(cc.xy(10,24), jpanel1, "odv.ifbi");
addLabelToPanel(cc.xy(2,34), jpanel1, "odv.isosState");
addFillComponents(jpanel1,
new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 },
new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30,31,32,33,34,35 });
return jpanel1;
}
protected JComponent createFormControl()
{
return buildScreen();
}
public boolean requestFocusInWindow() {
return iinmateId.requestFocusInWindow();
}
private void addComponentToPanel(CellConstraints cc, JComponent
thePanel, JComponent theComponent, String theName)
{
addComponentToPanel(cc, thePanel,theComponent, theName, false);
}
private void addComponentToPanel(CellConstraints cc, JComponent thePanel,
JComponent theComponent, String theName, boolean enabled)
{
theComponent.setEnabled(enabled);
theComponent.setName(theName);
thePanel.add(theComponent, cc);
}
private void addLabelToPanel(CellConstraints cc, JPanel thePanel,
String theName)
{
addLabelToPanel(cc, thePanel, theName, JLabel.TRAILING);
}
private void addLabelToPanel(CellConstraints cc, JPanel thePanel,
String theName, int HorizontalAlignment)
{
JLabel jlabel = new JLabel();
jlabel.setText(getMessage(theName+".label"));
jlabel.setHorizontalAlignment(HorizontalAlignment);
thePanel.add(jlabel,cc);
}
and the image