Package edu.spbstu.hoteldb.panels

Source Code of edu.spbstu.hoteldb.panels.LoginPanel

package edu.spbstu.hoteldb.panels;

import java.sql.SQLException;
import java.util.List;

import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import edu.spbstu.hoteldb.Main;
import edu.spbstu.hoteldb.handlers.LoginEventHandler;
import edu.spbstu.hoteldb.handlers.RegisterEventHandler;
import edu.spbstu.hoteldb.interfaces.Panel;

public class LoginPanel extends VBox implements Panel{
  final RoomSearchPanel rsearch = new RoomSearchPanel();

  @Override
  public void create(List<Object> args) {
    final TextArea results = (TextArea) args.get(0);
    final Main main = (Main) args.get(1);
    this.setSpacing(10);
    this.setPadding(new Insets(10, 10, 10, 10));
    TextField login = new TextField();
    login.setMaxWidth(200);
    login.setPromptText("Login");
    PasswordField pass = new PasswordField();
    pass.setMaxWidth(200);
    pass.setPromptText("Password");
    Button logbtn = new Button("Log in");
    logbtn.setOnAction(new LoginEventHandler(login, pass, results, main));
    Button regbtn = new Button("Register");
    regbtn.setOnAction(new RegisterEventHandler(results, main));
    HBox logbtns = new HBox(logbtn, regbtn);
    logbtns.setSpacing(15);
   
    rsearch.create(args);
   
    this.getChildren().addAll(login, pass, logbtns, rsearch);
  }
 
  @Override
  public void connect() throws ClassNotFoundException, SQLException {
    rsearch.connect();
  }

  @Override
  public void close() throws SQLException {
    rsearch.close();
  }
}
TOP

Related Classes of edu.spbstu.hoteldb.panels.LoginPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.