📄 applicationformpanel.java
字号:
columnMonthlyIncome.setDataType(com.borland.dx.dataset.Variant.DOUBLE);
columnMonthlyIncome.setCurrency(true);
columnMonthlyIncome.setRequired(true);
columnBirthdate.setColumnName("dob");
columnBirthdate.setDataType(com.borland.dx.dataset.Variant.DATE);
columnBirthdate.setRequired(true);
// Resourced, so a locale-specific edit mask is used
columnBirthdate.setEditMask(res.getString("DobEditMask"));
// Not resourced, so US currency is alsways used
columnMonthlyIncome.setEditMask("$##,###.##");
columnRentMortgagePayment.setEditMask("$##,###.##");
columnIdentification.setColumnName("identification");
columnIdentification.setEditMask("cccccccccc");
columnIdentification.setPrecision(10);
columnIdentification.setDataType(com.borland.dx.dataset.Variant.STRING);
columnPhone.setColumnName("phone");
columnPhone.setEditMask("ccccccccccccccccccccccccc");
columnPhone.setPrecision(25);
columnPhone.setRequired(true);
columnPhone.setDataType(com.borland.dx.dataset.Variant.STRING);
columnCountry.setColumnName("country");
columnCountry.setEditMask("ccccccccccccccccccccccccc");
columnCountry.setPrecision(25);
columnCountry.setDataType(com.borland.dx.dataset.Variant.STRING);
columnCountry.setRequired(true);
columnPostalCode.setColumnName("postalCode");
columnPostalCode.setEditMask("ccccccccccccccc");
columnPostalCode.setPrecision(15);
columnPostalCode.setDataType(com.borland.dx.dataset.Variant.STRING);
columnPostalCode.setRequired(true);
columnState.setColumnName("state");
columnState.setEditMask(">LL");
columnState.setPrecision(2);
columnState.setDataType(com.borland.dx.dataset.Variant.STRING);
columnState.setRequired(true);
columnAddress1.setColumnName("addr1");
columnAddress1.setDataType(com.borland.dx.dataset.Variant.STRING);
columnAddress1.setEditMask("cccccccccccccccccccccccccccccccccc");
columnAddress1.setPrecision(35);
columnAddress1.setRequired(true);
jPanel7.setLayout(gridLayout1);
gridLayout1.setHgap(5);
jPanel4.setLayout(gridLayout2);
gridLayout2.setColumns(1);
gridLayout2.setRows(2);
jPanel8.setLayout(gridLayout3);
gridLayout3.setColumns(1);
gridLayout3.setRows(2);
jPanel9.setLayout(gridLayout4);
gridLayout4.setRows(2);
jPanel11.setLayout(gridBagLayout1);
jPanel10.setLayout(gridLayout5);
gridLayout5.setRows(2);
jPanel12.setLayout(gridBagLayout2);
flowLayout1.setAlignment(FlowLayout.LEFT);
flowLayout1.setHgap(0);
flowLayout1.setVgap(0);
jPanel14.setLayout(flowLayout2);
phoneField.setColumns(20);
phoneField.setColumnName("phone");
phoneField.setDataSet(tableDataSetApplicantData);
flowLayout2.setAlignment(FlowLayout.LEFT);
flowLayout2.setHgap(0);
flowLayout2.setVgap(0);
identificationField.setColumns(10);
identificationField.setColumnName("identification");
identificationField.setDataSet(tableDataSetApplicantData);
flowLayout3.setAlignment(FlowLayout.LEFT);
flowLayout3.setHgap(0);
flowLayout3.setVgap(0);
birthdateField.setColumns(10);
birthdateField.setColumnName("dob");
birthdateField.setDataSet(tableDataSetApplicantData);
flowLayout4.setAlignment(FlowLayout.LEFT);
flowLayout4.setHgap(0);
flowLayout4.setVgap(0);
jPanel1.add(jPanel3, BorderLayout.NORTH);
jPanel3.add(jPanel7, null);
jPanel7.add(buttonSubmit, null);
jPanel7.add(buttonClear, null);
jPanel1.add(jdbStatusLabel, BorderLayout.SOUTH);
jPanel13.setLayout(flowLayout1);
this.add(jPanel1, BorderLayout.SOUTH);
this.add(formTitleLabel, BorderLayout.NORTH);
this.add(jPanel6, BorderLayout.EAST);
jPanel6.add(jPanel2, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
jPanel2.add(financialInfoLabel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0
,GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(8, 0, 4, 10), 0, 0));
jPanel2.add(monthlyIncomeField, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 4, 4), 0, 0));
jPanel2.add(rentMortagePaymentField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 4, 4), 0, 0));
jPanel2.add(monthlyIncomeLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 7, 0, 0), 42, 0));
jPanel2.add(rentMortgagePaymentLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 7, 1, 0), 0, 0));
jPanel6.add(jPanel5, new GridBagConstraints(0, 0, 1, 2, 0.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(10, 10, 10, 10), 0, 0));
jPanel5.add(imageLabel, BorderLayout.CENTER);
this.add(personalInfoPanel, BorderLayout.CENTER);
personalInfoPanel.add(address1Field, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
personalInfoPanel.add(address2Field, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
personalInfoPanel.add(jLabel1, new GridBagConstraints(1, 1, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(-2, -2, 0, 0), 0, 0));
personalInfoPanel.add(personalInfoLabel, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
personalInfoPanel.add(jPanel11, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
jPanel11.add(jPanel4, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
jPanel4.add(firstNameLabel, null);
jPanel4.add(firstNameField, null);
jPanel11.add(jPanel8, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
jPanel8.add(middleInitialLabel, null);
jPanel8.add(middleInitialField, null);
jPanel11.add(jPanel9, new GridBagConstraints(3, 0, 2, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
jPanel9.add(lastNameLabel, null);
jPanel9.add(lastNameField, null);
personalInfoPanel.add(jPanel10, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 5, 5), 0, 0));
jPanel10.add(jLabel2, null);
jPanel10.add(nameLabel, null);
personalInfoPanel.add(address1Label, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 5, 5), 0, 0));
personalInfoPanel.add(cityStateZipLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 5, 5), 0, 0));
personalInfoPanel.add(countryLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 5, 5), 0, 0));
personalInfoPanel.add(jPanel12, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
jPanel12.add(cityField, new GridBagConstraints(0, 0, 2, 1, 0.8, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
jPanel12.add(stateField, new GridBagConstraints(2, 0, 1, 1, 0.2, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
jPanel12.add(postalCodeField, new GridBagConstraints(3, 0, 2, 1, 0.7, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
personalInfoPanel.add(jPanel13, new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
jPanel13.add(countryField, null);
personalInfoPanel.add(jPanel14, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
jPanel14.add(phoneField, null);
personalInfoPanel.add(jPanel15, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
jPanel15.setLayout(flowLayout3);
jPanel15.add(identificationField, null);
personalInfoPanel.add(address2Label, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 5, 5), 0, 0));
personalInfoPanel.add(phoneLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
personalInfoPanel.add(identificationLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 5, 5), 0, 0));
personalInfoPanel.add(birthdateLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 5, 5), 0, 0));
personalInfoPanel.add(jPanel16, new GridBagConstraints(1, 8, 3, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
jPanel16.setLayout(flowLayout4);
jPanel16.add(birthdateField, null);
tableDataSetApplicantData.setColumns(new Column[] {columnFirstName, columnLastName, columnMiddleInitial, columnAddress1, columnAddress2, columnCity, columnState, columnPostalCode, columnCountry, columnPhone, columnIdentification, columnBirthdate, columnMonthlyIncome, columnRentMortgagePayment});
}
/**
* Validate the user input - Make sure required fields have been
* completed.
* @return boolean
*/
boolean validateForm() {
// Check for missing Required Columns
Column missingColumn = FindMissingRequired.missingColumn(tableDataSetApplicantData);
if (missingColumn != null) {
Component missing = FindMissingRequired.findColumnTextField(this, missingColumn.getColumnName());
if (missing != null) {
missing.requestFocus();
setStatusText(res.getString("Please_enter_a_value"));
}
return false;
}
else {
setStatusText(" ");
}
return true;
}
/**
* The SUBMIT button was pressed:
* Submit the entered data to the Applet for Credit Approvals
* @param event ActionEvent
*/
void buttonSubmit_actionPerformed(ActionEvent event) {
if (creditApprovalApplet != null && creditApprovalApplet.isClientValidationEnabled()) {
if (!validateForm()) {
return;
}
}
try {
final applicantInfoStruct appInfo = new applicantInfoStruct();
creditApprovalStruct creditCardInfo;
appInfo.firstName = tableDataSetApplicantData.getString("firstName");
appInfo.MI = tableDataSetApplicantData.getString("mi");
appInfo.lastName = tableDataSetApplicantData.getString("lastName");
appInfo.DOB = tableDataSetApplicantData.getDate("dob").toString();
appInfo.phone = tableDataSetApplicantData.getString("phone");
appInfo.address1 = tableDataSetApplicantData.getString("addr1");
appInfo.address2 = tableDataSetApplicantData.getString("addr2");
appInfo.city = tableDataSetApplicantData.getString("city");
appInfo.state = tableDataSetApplicantData.getString("state");
appInfo.postalCode = tableDataSetApplicantData.getString("postalCode");
appInfo.country = tableDataSetApplicantData.getString("country");
appInfo.PID = tableDataSetApplicantData.getString("identification");
appInfo.monthlyIncome = tableDataSetApplicantData.getDouble("monthlyIncome");
appInfo.rentMortgagePayment = tableDataSetApplicantData.getDouble("rentMortgagePayment");
// launch server processing in a separate thread (enables server callbacks to update UI)
Thread t = new Thread() {
public void run() {
creditApprovalApplet.applyForCard(appInfo);
}
};
t.start();
}
catch (Exception e) {
System.err.println("ApplicationFormPanel: exception applying for card");
e.printStackTrace();
}
}
/**
* The Clear button was pressed. Reset all columns to NULL
* @param ae ActionEvent
*/
void buttonClear_actionPerformed(ActionEvent ae) {
try {
tableDataSetApplicantData.clearValues();
firstNameField.requestFocus();
}
catch (Exception e) {
System.err.println(e);
}
}
/**
* Set the text in the status bar
* @param text String
*
*/
private void setStatusText(String text) {
jdbStatusLabel.setText(text);
}
/**
* Implementation of Observable interface.
* Called by server callback object to display
* status messages on client.
*
* @param obs Observable
* @param arg Object
*/
public void update(Observable obs, final Object arg) {
// server callbacks are in a different thread, use invokeLater to
// ensure messages are painted in the AWT event thread
SwingUtilities.invokeLater(new Runnable() {
public void run() {
setStatusText((String) arg);
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -