Advertisement
Guest User

Untitled

a guest
Nov 20th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.94 KB | None | 0 0
  1. import java.awt.Dimension;
  2. import java.awt.Toolkit;
  3. import java.util.ArrayList;
  4. import java.sql.*;
  5.  
  6. import javafx.application.Application;
  7. import javafx.event.ActionEvent;
  8. import javafx.event.EventHandler;
  9. import javafx.geometry.Insets;
  10. import javafx.scene.Scene;
  11. import javafx.scene.control.Button;
  12. import javafx.scene.control.TextArea;
  13. import javafx.scene.control.TextField;
  14. import javafx.scene.layout.StackPane;
  15. import javafx.scene.layout.VBox;
  16. import javafx.stage.Stage;
  17.  
  18.  
  19.  
  20. public class GUI extends Application {
  21.    
  22.     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  23.    
  24.     Button createTables;
  25.     Button populateTables;
  26.     Button selectAll;
  27.     Button queries;
  28.     Button query1;
  29.     Button query2;
  30.     Button query3;
  31.     Button query4;
  32.     Button query5;
  33.     Button dropTables;
  34.     TextArea output;
  35.    
  36.    
  37.     public static void main(String[] args){
  38.         launch(args);
  39.        
  40.     }
  41.    
  42.     @Override
  43.     public void start(Stage primaryStage) throws Exception {
  44.        
  45.    
  46.         // Stage set-up
  47.         Stage myStage = primaryStage;
  48.         myStage.setTitle("Online Job Posting");
  49.         double screenWidth = screenSize.getWidth();
  50.         double screenHeight = screenSize.getHeight();
  51.         createTables = new Button("Create Tables");
  52.         populateTables = new Button("Populate Tables");
  53.         selectAll = new Button("Select All");
  54.         queries = new Button("Queries");
  55.         query1 = new Button("Query1");
  56.         query2 = new Button("Query2");
  57.         query3 = new Button("Query3");
  58.         query4 = new Button("Query4");
  59.         query5 = new Button("Query5");
  60.         dropTables = new Button("Drop Tables");
  61.         output = new TextArea();
  62.        
  63.         VBox vBox = new VBox();
  64.         vBox.setPrefWidth(100);
  65.         vBox.setPadding(new Insets(5, 5, 10, 5));
  66.         vBox.setSpacing(2);
  67.        
  68.         createTables.setMinWidth(vBox.getPrefWidth());
  69.         populateTables.setMinWidth(vBox.getPrefWidth());
  70.         selectAll.setMinWidth(vBox.getPrefWidth());
  71.         queries.setMinWidth(vBox.getPrefWidth());
  72.         query1.setMinWidth(vBox.getPrefWidth());
  73.         query2.setMinWidth(vBox.getPrefWidth());
  74.         query3.setMinWidth(vBox.getPrefWidth());
  75.         query4.setMinWidth(vBox.getPrefWidth());
  76.         query5.setMinWidth(vBox.getPrefWidth());
  77.         dropTables.setMinWidth(vBox.getPrefWidth());
  78.        
  79.         createTables.setOnAction(new EventHandler<ActionEvent>() {
  80.             @Override
  81.             public void handle (ActionEvent e)
  82.             {
  83.                 //SQL Functionality goes in here
  84.                 String username = "clrosier";
  85.                 String password = "apple321";
  86.                 Connection c;
  87.                 try {
  88.                     Class.forName("oracle.jdbc.driver.OracleDriver");
  89.                     c = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl", username, password);
  90.                     Statement stmt = c.createStatement();
  91.                     String query = "CREATE TABLE table_name ( PersonID int, OtherAtt VARCHAR2(30), OtherAtt2 VARCHAR2(30) );";
  92.                     ResultSet rset = stmt.executeQuery(query);
  93.                 } catch (ClassNotFoundException ex) {
  94.                     // TODO Auto-generated catch block
  95.                     ex.printStackTrace();
  96.                 } catch (SQLException ex) {
  97.                     // TODO Auto-generated catch block
  98.                     ex.printStackTrace();
  99.                 }
  100.             }
  101.         });
  102.        
  103.         populateTables.setOnAction(new EventHandler<ActionEvent>() {
  104.             @Override
  105.             public void handle (ActionEvent e)
  106.             {
  107.                 //SQL Functionality goes in here
  108.             }
  109.         });
  110.        
  111.         selectAll.setOnAction(new EventHandler<ActionEvent>() {
  112.             @Override
  113.             public void handle (ActionEvent e)
  114.             {
  115.                 //SQL Functionality goes in here
  116.             }
  117.         });
  118.        
  119.         queries.setOnAction(new EventHandler<ActionEvent>() {
  120.             @Override
  121.             public void handle (ActionEvent e)
  122.             {
  123.                 //SQL Functionality goes in here
  124.             }
  125.         });
  126.        
  127.         query1.setOnAction(new EventHandler<ActionEvent>() {
  128.             @Override
  129.             public void handle (ActionEvent e)
  130.             {
  131.                 //SQL Functionality goes in here
  132.             }
  133.         });
  134.        
  135.         query2.setOnAction(new EventHandler<ActionEvent>() {
  136.             @Override
  137.             public void handle (ActionEvent e)
  138.             {
  139.                 //SQL Functionality goes in here
  140.             }
  141.         });
  142.        
  143.         query3.setOnAction(new EventHandler<ActionEvent>() {
  144.             @Override
  145.             public void handle (ActionEvent e)
  146.             {
  147.                 //SQL Functionality goes in here
  148.             }
  149.         });
  150.        
  151.         query4.setOnAction(new EventHandler<ActionEvent>() {
  152.             @Override
  153.             public void handle (ActionEvent e)
  154.             {
  155.                 //SQL Functionality goes in here
  156.             }
  157.         });
  158.        
  159.         query5.setOnAction(new EventHandler<ActionEvent>() {
  160.             @Override
  161.             public void handle (ActionEvent e)
  162.             {
  163.                 //SQL Functionality goes in here
  164.                 output.setText("query5..");
  165.             }
  166.         });
  167.        
  168.         dropTables.setOnAction(new EventHandler<ActionEvent>() {
  169.             @Override
  170.             public void handle (ActionEvent e)
  171.             {
  172.                 //SQL Functionality goes in here
  173.                 output.setText("droptables..");
  174.             }
  175.         });
  176.        
  177.         output.setMinSize(290, 245);
  178.         output.setMaxSize(290, 245);
  179.         output.setTranslateX(105);
  180.         output.setTranslateY(-245);
  181.        
  182.         vBox.getChildren().addAll(createTables, populateTables, queries, query1, query2, query3, query4, query5, dropTables, output);
  183.        
  184.         Scene myScene = new Scene(vBox, 400, 250);
  185.         myStage.setScene(myScene);
  186.         myStage.setResizable(false);
  187.        
  188.         myStage.show();
  189.     }
  190.    
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement