Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package application;
- import javafx.scene.Scene;
- import javafx.stage.Stage;
- import javafx.scene.text.Font;
- import javafx.scene.text.Text;
- import javafx.scene.control.Button;
- import javafx.scene.control.TextArea;
- import javafx.scene.Group;
- import javafx.scene.Node;
- import java.awt.TextField;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.layout.GridPane;
- import com.mysql.jdbc.PreparedStatement;
- public class HomePage extends Stage {
- public HomePage(String userName) {
- // start connecting to database
- try {
- Connection con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/Online_Book_Store?useSSL=false", "root", "ahmed666" );
- PreparedStatement p = (PreparedStatement) con.prepareStatement("select USER_NAME from USERS");
- ResultSet rs = p.executeQuery();
- while (rs.next()) {
- String name = rs.getString("USER_NAME");
- System.out.println(name);
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // Text Area for search label
- TextField search = new TextField("");
- //search button
- Button buttonFour = new Button("Search by name");
- //search button
- Button buttonFive = new Button("Search by ISBN");
- //personal info button
- Button buttonOne = new Button("Edit personal info");
- //Shopping cart button
- Button buttonTwo = new Button("Shopping cart");
- //Shopping cart button
- Button buttonThree = new Button("Logout");
- //Styling nodes
- buttonOne.setStyle("-fx-background-color: darkslateblue; -fx-text-fill: white;");
- buttonTwo.setStyle("-fx-background-color: darkslateblue; -fx-text-fill: white;");
- buttonThree.setStyle("-fx-background-color: darkslateblue; -fx-text-fill: white;");
- buttonFour.setStyle("-fx-background-color: darkslateblue; -fx-text-fill: white;");
- buttonFive.setStyle("-fx-background-color: darkslateblue; -fx-text-fill: white;");
- //Creating a Grid Pane
- GridPane gridPane = new GridPane();
- //Setting size for the pane
- gridPane.setMinSize(800, 600);
- //Setting the padding
- gridPane.setPadding(new Insets(10, 10, 10, 10));
- //Setting the vertical and horizontal gaps between the columns
- gridPane.setVgap(30);
- gridPane.setHgap(30);
- //Setting the Grid alignment
- gridPane.setAlignment(Pos.CENTER);
- //Arranging all the nodes in the grid
- gridPane.add(buttonFive, 0, 0);
- gridPane.add(buttonFour, 2, 0);
- gridPane.add(buttonOne, 2, 1);
- gridPane.add(buttonTwo, 2, 2);
- gridPane.add(buttonThree, 2, 3);
- gridPane.add(search, 1, 0);
- Scene scene = new Scene(gridPane);
- scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
- setScene(scene);
- setTitle(userName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement