Database Reference
In-Depth Information
constructor to call our method right after the call to
jbInit()
. No matter what IDE you are using, you will
want to have a similar segregation of code.
Login Screen Constructors
In Listing 12-4, you can see how we call
ojsInit()
right after the call to
jbInit()
in the constructor.
Additionally, we have provided a third constructor that takes a
Frame
class. We will call that constructor,
rather than the default constructor, and provide a reference to our main application class,
parent
. Then
when the login process is complete, we will use this reference to return to our application.
Listing 12-4.
Login Screen Constructors
public class
Login extends JDialog
{
public
Login
() {
this(null, "", false);
}
public
Login
(Frame parent, String title, boolean modal) {
super(parent, title, modal);
try {
jbInit();
ojsInit();
} catch (Exception e) {
e.printStackTrace();
}
}
public
Login(Frame parent)
{
// For Oracle Java Secure, call this constructor
this(parent, "two-factor Authentication Login", true);
}
public
Login(Frame parent, String applicationID, String appClassName)
{
// This replacement constructor is used when managing a selected application
super(parent, "two-factor Authentication Login", true);
try {
this.applicationID = applicationID;
Class applicationClass = Class.forName(appClassName);
appClass = applicationClass.newInstance();
jbInit();
ojsInit();
} catch (Exception e) {
System.out.println("Specified application class is not available");
System.exit(0);
}
}
...
There is also a fourth constructor that bypasses (repeats code from) the other constructors. That
fourth constructor takes an alternate application name and inner class name. When called, this