Foundface mainly implement password retrieval function and interface.
Import javafx.application.Application;
Import Javafx.event.EventHandler;
Import Javafx.geometry.Insets;
Import Javafx.geometry.Pos;
Import Javafx.scene.Cursor;
Import Javafx.scene.Scene;
Import Javafx.scene.control.Button;
Import Javafx.scene.control.Label;
Import Javafx.scene.control.PasswordField;
Import Javafx.scene.control.TextField;
Import Javafx.scene.image.Image;
Import Javafx.scene.image.ImageView;
Import javafx.scene.input.MouseEvent;
Import Javafx.scene.layout.GridPane;
Import Javafx.scene.layout.HBox;
Import Javafx.scene.layout.VBox;
Import Javafx.scene.paint.Color;
Import Javafx.stage.Stage;
Import javafx.stage.WindowEvent;
public class Foundface extends application{
public void Start (Stage primarystage) {
Sqllink sql=new Sqllink ();
Image over=new Image ("over.jpg");
ImageView headimage=new ImageView (over);
Button Btsubmit=new button ("submit");
Btsubmit.setpadding (New Insets (5,30,5,30));
Btsubmit.setcursor (Cursor.hand);
Button Btexit=new button ("Cancel");
Btexit.setpadding (New Insets (5,30,5,30));
Btexit.setcursor (Cursor.hand);
Button Btcheck=new button ("Show Secret Protection Problem");
Btcheck.setpadding (New Insets (5,27,5,27));
Btcheck.setcursor (Cursor.hand);
Label Lbusername=new label ("Account Number:");
Label Lbusercheck=new label ();
Label Lbquestion1=new label ("Secret Protection Question:");
Label Lbquestion2=new label ();
Label Lbanswer=new label ("Answer:");
Label Lbpassword1=new label ("New Password:");
Label Lbpassword2=new label ("Confirm Password:");
TextField tfusername=new TextField ();
Tfusername.setprefcolumncount (12);
TextField tfanswer=new TextField ();
Tfanswer.setprefcolumncount (12);
Passwordfield pfpassword1=new Passwordfield ();
Pfpassword1.setprefcolumncount (12);
Passwordfield pfpassword2=new Passwordfield ();
Pfpassword2.setprefcolumncount (12);
Gridpane pane1=new Gridpane ();
Pane1.setalignment (Pos.center);
Pane1.setpadding (New Insets (15,0,0,0));
Pane1.sethgap (10);
Pane1.setvgap (10);
Pane1.add (lbusername,0,0);
Pane1.add (tfusername,1,0);
Pane1.add (lbquestion1,0,1);
Pane1.add (btcheck,1,1);
Pane1.add (lbanswer,0,2);
Pane1.add (tfanswer,1,2);
Pane1.add (lbpassword1,0,3);
Pane1.add (pfpassword1,1,3);
Pane1.add (lbpassword2,0,4);
Pane1.add (pfpassword2,1,4);
Gridpane pane2=new Gridpane ();
Pane2.setalignment (Pos.center);
Pane2.setpadding (New Insets ( -15,0,10,0));
Pane2.sethgap (20);
Pane2.setvgap (10);
Pane2.add (btsubmit,0,3);
Pane2.add (btexit,1,3);
VBox vbox=new VBox ();
Vbox.setalignment (Pos.center);
Vbox.setpadding (New Insets (0,0,0,0));
Vbox.getchildren (). AddAll (Headimage,pane1,pane2);
btcheck.setonmouseclicked (New eventhandler<mouseevent> () {
public void handle (MouseEvent arg0) {
if (Sql.checkuser (Tfusername.gettext ())) {
Lbquestion2.settext (Sql.getquestion (Tfusername.gettext ()));
Lbquestion2.setpadding (New Insets (5,5,5,5));
Lbusercheck.settext (Tfusername.gettext ());
Lbquestion2.settextfill (Color.Black);
Lbusercheck.setpadding (New Insets (5,25,5,5));
HBox hbox=new HBox ();
Button Button=new button ("Re-enter");
Button.setcursor (Cursor.hand);
button.setonmouseclicked (New eventhandler<mouseevent> () {
public void handle (MouseEvent arg0) {
Pane1.getchildren (). Remove (HBox);
Pane1.add (tfusername, 1, 0);
Pane1.add (Btcheck, 1, 1);
}
});
Button.setpadding (New Insets (5,10,5,10));
Hbox.getchildren (). AddAll (Lbusercheck,button);
Pane1.getchildren (). Remove (Btcheck);
Pane1.getchildren (). Remove (Tfusername);
Pane1.add (HBox, 1, 0);
Pane1.add (LbQuestion2, 1, 1);
}else{
Lbquestion2.settext ("This account is not found! ");
Lbquestion2.settextfill (color.red);
Lbquestion2.setpadding (New Insets (5,5,5,5));
Pane1.getchildren (). Remove (Btcheck);
HBox hbox=new HBox ();
Button Button=new button ("Re-enter");
Button.setcursor (Cursor.hand);
button.setonmouseclicked (New eventhandler<mouseevent> () {
public void handle (MouseEvent arg0) {
Pane1.getchildren (). Remove (HBox);
Pane1.add (Btcheck, 1, 1);
}
});
Button.setpadding (New Insets (5,10,5,10));
Hbox.getchildren (). AddAll (Lbquestion2,button);
Pane1.add (HBox, 1, 1);
}
}
});
btsubmit.setonmouseclicked (New eventhandler<mouseevent> () {
public void handle (MouseEvent e) {
Label Lbmessage=new label ();
Gridpane pane =new Gridpane ();
Stage Stage=new stage ();
if (Sql.changeuser (Tfusername.gettext (), Pfpassword1.gettext ())) {
Lbmessage.settext ("Change password successfully!") ");
Button Button=new button ("OK");
Button.setpadding (New Insets (5,30,5,30));
Button.setcursor (Cursor.hand);
button.setonmouseclicked (New eventhandler<mouseevent> () {
public void handle (MouseEvent e) {
New Loginface (). Start (New Stage ());
Stage.close ();
Primarystage.close ();
}
});
Pane.add (button,0,1);
Pane.setvgap (20);
}else{
Lbmessage.settext ("Secret Insurance answer Error!") Please re-enter! ");
}
Pane.add (lbmessage,0,0);
Pane.setalignment (Pos.center);
Stage.settitle ("Change hint");
Stage.setscene (New Scene (pane));
Stage.setheight (120);
Stage.setwidth (250);
Stage.geticons (). Add (New Image ("Char_bg.png"));
Stage.show ();
}
});
btexit.setonmouseclicked (New eventhandler<mouseevent> () {
public void handle (MouseEvent e) {
New Loginface (). Start (New Stage ());
Primarystage.close ();
}
});
Scene scene=new scene (vbox,400,335);
Primarystage.settitle ("The soldier who recovered the sniper tank!" ");
Primarystage.setwidth (400);
Primarystage.setheight (335);
Primarystage.setresizable (FALSE);
Primarystage.geticons (). Add (New Image ("Char_bg.png"));
Primarystage.setscene (Scene);
Primarystage.setoncloserequest (New eventhandler<windowevent> () {
public void handle (WindowEvent e) {
New Loginface (). Start (New Stage ());
Primarystage.close ();
}
});
Primarystage.show ();
}
}
Windows typing game-Password retrieval