Authenticating and Connecting to JDBC Databases

    String driver = "org.postgresql.Driver";
    String url = "jdbc:postgresql://localhost/adventure";
    JDBCLoginService svc = new JDBCLoginService(driver, url);
    JXLoginPanel.showLoginFrame(svc);
                        

Showing a Login Frame

    JDBCLoginService svc = new JDBCLoginService(driver, url);
    JXLoginPanel.showLoginFrame(svc);
                        

Customizing a Login Frame

    JDBCLoginService svc = new JDBCLoginService(driver, url);
    JXLoginPanel panel = new JXLoginPanel(svc);
    panel.setBannerText("MyApp :: Login");
    panel.setUserName("guest");
    panel.setBanner(customImage);
    JXLoginPanel.JXLoginFrame frame = JXLoginPanel.showLoginFrame(panel);
    frame.setTitle("Custom Login Title");
                        

Adapt a Custom Login Dialog

Note: This code is part of Romain Guy's custom login dialog demo. It won't compile as is, you should use this example as a prototype for how to adapt authentication into your own situation

public class LoginDialog extends JDialog implements FadeListener {
  //...
  private void buildLoginForm() {
    passwordField.addActionListner(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        glassPane.setVisible(true);
        new Thread() {
          public void run() {
            //perform the login procedures
            loginService.addLoginListener(
                new org.jdesktop.swingx.auth.LoginListener() {
              /**
               *  Called by the JXLoginPanel in the event of a login failure
               *
               * @param source panel that fired the event
               */
              public void loginFailed(LoginEvent source) {
                glassPane.setVisible(false);
                setVisible(false);
              }

              /**
               *  Called by the JXLoginPanel when the Authentication
               *  operation is started.
               * @param source panel that fired the event
               */
              public void loginStarted(LoginEvent source) {}

              /**
               *  Called by the JXLoginPanel in the event of a login
               *  cancellation by the user.
               *
               * @param source panel that fired the event
               */
              public void loginCanceled(LoginEvent source) {
                glassPane.setVisible(false);
                setVisible(false);
              }

              /**
               *  Called by the JXLoginPanel in the event of a
               *  successful login.
               *
               * @param source panel that fired the event
               */
              public void loginSucceeded(LoginEvent source) {
                glassPane.setVisible(false);
                setVisible(false);
              }
            });
            
            try {
              loginService.startAuthentication(
                loginField.getText(), 
                passwordField.getText().toCharArray(), 
                "java.net");
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        }.start();
      }
    });
  }
  //...
}