Database Reference
In-Depth Information
JLabel jLabel1 = new JLabel();
jLabel1.setText("Working. Please wait!");
jLabel1.setBounds(new Rectangle(5, 5, 220, 35));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setFont(new Font("Tahoma", 0, 16));
jPanel1.add(jLabel1, null);
sayWaitDialog.getContentPane().add(jPanel1, null);
Login.center(sayWaitDialog) ;
}
Notice that the last line in the definition of sayWaitDialog is a call to our center() method to place
the dialog in the center of the monitor. The last thing to mention about this dialog is in the first line. We
set the dialog to do nothing on close. We disable the ability of the user to click on the X in the top right
corner of the window to close the dialog. We actually never open or close the dialog; we simply make it
visible when we want it and invisible when we don't.
Background Processing Thread
Now let's look at the ojsInit() method that we use to set additional properties of the Login screen GUI
and to jump-start to login process. Listing 12-6 shows the code. In the bottom half of the method code,
we see the call to set the static Login.sayWaitDialog to be visible and our call to center the Login screen
and then make it visible. We also slightly modify the Login Screen by setting the reEnterLabel to be
invisible. If the user enters an incorrect two-factor authentication code, we will set that help message to
be visible.
Listing 12-6. Self-Managed GUI Initialization and Background Processing Thread
private static String applicationID = "OJSADMIN";
private static Object appClass = new InnerRevLvlClass() ;
private void ojsInit() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
OracleJavaSecure. setAppContext ( applicationID , appClass , "");
// Under some circumstances, this will throw an exception
// if OS User not allowed, also test isAppverOK
OracleJavaSecure.getAppConnections();
// on success, original error message will be blanked out
if (OracleJavaSecure.isAppverOK())
twoFactCodeTextField.setText("");
Login.sayWaitDialog.setVisible(false) ;
}
});
Login.sayWaitDialog.setVisible(true) ;
Login.center(this) ;
reEnterLabel.setVisible(false);
appIDLabel.setText(applicationID);
this.setVisible(true) ;
return;
}
 
Search WWH ::




Custom Search