Package edu.spbstu.hoteldb.panels

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

package edu.spbstu.hoteldb.panels;

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

import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.GridPane;
import edu.spbstu.hoteldb.handlers.ClientSearchEventHandler;
import edu.spbstu.hoteldb.handlers.NameFilter;
import edu.spbstu.hoteldb.handlers.NumFilter;
import edu.spbstu.hoteldb.interfaces.Panel;

public class ClientSearchPanel extends GridPane implements Panel {

  private Connection connect;
 
  @Override
  public void create(List<Object> args) {
    this.setHgap(10);
    this.setVgap(10);
   
    TextArea results = (TextArea) args.get(0);
    connect = (Connection) args.get(1);
   
    Label lsearch = new Label("Client search");
   
    Label lid = new Label("Id: ");
    TextField tfid = new TextField();
    tfid.addEventFilter(KeyEvent.KEY_TYPED, new NumFilter());
   
    Label lname = new Label("Name: ");
    TextField tfname = new TextField();
    tfname.addEventFilter(KeyEvent.KEY_TYPED, new NameFilter());
   
    Button btnsearch = new  Button("Search");
    List<Node> arg = new LinkedList<Node>();
    arg.add(tfid); arg.add(tfname);
    btnsearch.setOnAction(new ClientSearchEventHandler(results, connect, arg));
   
    this.add(lsearch, 0, 0);
    this.add(lid, 0, 1);
    this.add(tfid, 1, 1);
    this.add(lname, 0, 2);
    this.add(tfname, 1, 2);
    this.add(btnsearch, 0, 3);
  }
 
  @Override
  public void connect() throws ClassNotFoundException, SQLException {   
  }
 
  @Override
  public void close() throws SQLException {
  }

}
TOP

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

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.