desktop/desktop-sample/src/main/java/cz/xelfi/quoridor/desktop/sample/LoginAction.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 14 Sep 2010 08:30:37 +0200
branchdesktop
changeset 263 ac802aa234fc
child 268 13fe01081e23
permissions -rw-r--r--
Login panel
     1 /*
     2  * To change this template, choose Tools | Templates
     3  * and open the template in the editor.
     4  */
     5 package cz.xelfi.quoridor.desktop.sample;
     6 
     7 import java.awt.event.ActionEvent;
     8 import java.awt.event.ActionListener;
     9 import org.openide.DialogDisplayer;
    10 import org.openide.NotifyDescriptor;
    11 import org.openide.util.NbBundle;
    12 
    13 public final class LoginAction implements ActionListener {
    14 
    15     @Override
    16     public void actionPerformed(ActionEvent e) {
    17         LoginPanel lp = new LoginPanel();
    18         NotifyDescriptor nd = new NotifyDescriptor(
    19             lp,
    20             NbBundle.getMessage(LoginAction.class, "LoginAction.title"),
    21             NotifyDescriptor.OK_CANCEL_OPTION,
    22             NotifyDescriptor.QUESTION_MESSAGE, null, null
    23         );
    24         Object res = DialogDisplayer.getDefault().notify(nd);
    25         if (res == NotifyDescriptor.OK_OPTION) {
    26             if (!Quoridor.getDefault().login(lp.getLogin(), lp.getPassword())) {
    27                 nd = new NotifyDescriptor.Message(
    28                     NbBundle.getMessage(LoginAction.class, "LoginAction.fail")
    29                 );
    30                 DialogDisplayer.getDefault().notify(nd);
    31             }
    32         }
    33     }
    34 }