-
Notifications
You must be signed in to change notification settings - Fork 0
/
VoteMain.java
380 lines (295 loc) · 13.1 KB
/
VoteMain.java
1
import javafx.scene.Scene;import javafx.stage.Stage;import javafx.application.Application;import javafx.scene.text.*;//Text, Fontimport javafx.scene.effect.*; // Reflection, DropShadowimport javafx.scene.paint.Color;import javafx.scene.layout.*;//HBox BorderPaneimport javafx.geometry.*;// Pos, Insetsimport javafx.scene.control.*;// TextField, Button, Labelimport javax.swing.*;// JOptionPaneimport javafx.scene.image.*;//Image , ImageViewimport java.io.*;import java.util.*;// List, OservableList, ArrayList// note always, do this// create the effects, and attributes first and add them to nodespublic class VoteMain extends Application{ public static void main(String[] args) { launch(args); } Stage stage; Scene accreditScene;// accredit scene Scene voteScene;// vote scene Scene procedureScene; //Nodes for accreditScene (Scene1) ChoiceBox<String> chooseSchool; ChoiceBox<String> chooseDepts; ChoiceBox<String> chooseYear; HBox topBox; Image fceLogo; ImageView topLeft; TilePane bottomTile; Text welcomeText; Label matricNumLabel; TextField matric; Button accredit; Text fepictxt; HBox bx; GridPane centerNode; BorderPane accreditSceneBorder; // Nodes for VoteScene (Scene2) Text info; HBox termsAndConditions; BorderPane borderScn2; RadioButton confirmTandC; TilePane tc; HBox scn2Top; Text scn2topText; Button goToScene3From2; Button goToScene2From3; Text info; //Scene Three Node.. () Text procedureTxt; HBox scn3Top; TilePane bottomTileForScn3; HBox procedureHolder; Text scn3TopText; Button goToScene4From3; //Scene four nodes Button about1, about2; Image linus; Image doug; Scene votePresidentCan; HBox scn4Top; // TilePane bottomTileForScn4; GridPane holdAspirantImage; Text scn4TopText; ToggleGroup togglePresi; public void start(Stage primaryStage){ stage = primaryStage; //Create text to stay up there Text topText = new Text("FEDERAL COLLEGE OF EDUCATION(TECH)AKOKA STUDENT UNION\n\t\t\tFECOETSU-ELECTION MANAGER"); topText.setId("topText"); topText.setFont(Font.font("Georgia", FontWeight.BOLD, 15)); chooseSchool = new ChoiceBox<String>(); chooseSchool.getItems().addAll("Science","Vocational", "Technical","PES","Business"); chooseSchool.setValue("Science"); //chooseSchool.setOnAction(); chooseDepts = new ChoiceBox<String>(); chooseYear = new ChoiceBox<String>(); // fce logo _ topRight Image fceLogo = new Image("file:c:Users\\Danny\\Desktop\\Vote\\Images\\topImg1.jpg"); ImageView topLeft = new ImageView(fceLogo); topLeft.setFitWidth(50); topLeft.setFitHeight(50); //Set an HBox on the top HBox topBox = new HBox(); topBox.setId("topBox"); topBox.setAlignment(Pos.CENTER); topBox.getChildren().addAll(topLeft,topText); //Create the leftPart wit a VBox TilePane bottomTile = new TilePane(); bottomTile.setId("bottomTile"); /* GridPane of the work area Features of the work area i.e the center of border pane Text that give a little information */ // Text to add to Grid pane String wlcmTxt = "Please input your\n matric number to get accredited"; Text welcomeText = new Text(wlcmTxt); welcomeText.setId("welcomeText"); welcomeText.setFont(Font.font("Lucida Calligraphy", FontWeight.BOLD, 15)); Label matricNumLabel = new Label("MATRIC_NUMBER:\n"); matricNumLabel.setFont(Font.font("Tahoma", FontWeight.BOLD, 15)); //labels for choice boxes Label selectDeptLbl = new Label("Department"); Label selectSchoolLbl = new Label("School:"); selectSchoolLbl.setFont(Font.font("Tahoma", FontWeight.BOLD, 15)); selectDeptLbl.setFont(Font.font("Tahoma", FontWeight.BOLD, 15)); TextField matric = new TextField(); matric.setPromptText("Enter Matric number here"); matric.setMinWidth(5); matric.setPrefSize(30,10); Button accredit = new Button("Accredit"); accredit.setOnAction( e -> { switchToTermsAndCond(); }); //Box to hold Fepic SUG Label in the GridPane Text fepictxt = new Text("FECOEUTSU / FEPIC "); fepictxt.setFont(Font.font("Comic Sans MS", FontWeight.BOLD, 30)); HBox bx = new HBox(); bx.setId("bx"); bx.setAlignment(Pos.CENTER); bx.getChildren().add(fepictxt); // GridPane to hold welcome text, and Label and TextField(Matric number) GridPane centerNode = new GridPane(); centerNode.setVgap(5); centerNode.setHgap(5); centerNode.setAlignment(Pos.CENTER); centerNode.add(welcomeText,0,0,2,1);// start adding nodes pf grid below centerNode.add(matricNumLabel,0,3); centerNode.add(matric,1,3); centerNode.add(selectSchoolLbl,0,4);// add label for school selection centerNode.add(chooseSchool,1,4);// add comboBox for school selection centerNode.add(selectDeptLbl,0,5);// add label for school selection centerNode.add(chooseDepts,1,5);// add choice box for dept selection centerNode.setPadding(new Insets(25,25,25,25)); centerNode.add(accredit,1,7); //Create border and add nodes for Scene1 BorderPane accreditSceneBorder = new BorderPane(); accreditSceneBorder.setTop(topBox); accreditSceneBorder.setBottom(bottomTile); accreditSceneBorder.setCenter(centerNode); Scene accreditScene = new Scene(accreditSceneBorder,900,600, Color.BLACK);// scene to resize 600, 900 primaryStage.setScene(accreditScene); primaryStage.getIcons().add(new Image("file:C:\\Users\\DANNY\\Desktop\\Vote\\images\\lock.png")); primaryStage.setTitle("FECOETSU-VOTE"); primaryStage.setFullScreen(false); primaryStage.show();//#2A5058 /* This marks the end of the first Scene (Beautiful code) */ // getting the text ready for second scene Text scn2topText = new Text("FEDERAL COLLEGE OF EDUCATION(TECH)AKOKA STUDENT UNION\n\t\t\tFECOETSU-ELECTION MANAGER"); scn2topText.setFont(Font.font("Georgia", FontWeight.BOLD, 15)); scn2topText.setId("scn2topText"); HBox scn2Top = new HBox(); scn2Top.setId("scn2Top"); scn2Top.setAlignment(Pos.CENTER); scn2Top.getChildren().add(scn2topText); String scene2Info = "TERMS AND CONDITIONS\n Welcome, you are Eligible to vote, Click the next button to commence the process\n Here are the rules and procedures,\n1. No null votes i.e You can only vote by clicking, and you cannot vote for two candidates at a time\n\n2. Click the Radio button next to the name of your preffered candidate\n\n3. Click on the VOTE button to go to the next SUG role/post to vote\n\n4. At the end of the whole process, you can click confirm votes to confirm your decisions\n5. Click Confirm Votes on the Last page to Send your RESPONSE.\n\n NOTE: Please agree to terms and conditions before proceeding\n\n\nVOTE WISELY"; // Text to stay in gridPane Text info = new Text(scene2Info); info.setFont(Font.font("Comic Sans MS", FontWeight.BOLD, 15)); //Radio button for accepting terms and condition confirmTandC = new RadioButton("Accept Terms and Conditions"); goToScene3From2 = new Button("Next"); goToScene3From2.setOnAction( e ->{ switchToProcedures(); });// next and previous button for scene 2; goToScene2From3 = new Button("Previous");// we do not need this previous button. //HBox to stay in Grid Pane at the top to hold terms and condiitions TilePane tc = new TilePane(); tc.setId("tc");// giving this a little more tatste tc.getChildren().addAll(goToScene2From3, confirmTandC, goToScene3From2); tc.setAlignment(Pos.CENTER); HBox termsAndConditions = new HBox(); termsAndConditions.setAlignment(Pos.CENTER); termsAndConditions.getChildren().addAll(info); // Terms and conditions Scene BorderPane borderScn2 = new BorderPane(); borderScn2.setCenter(termsAndConditions); borderScn2.setTop(scn2Top); borderScn2.setBottom(tc); voteScene = new Scene(borderScn2, 900,600); /* Lets get started with the third scene */ // Some magic for scene 3 Text scn3TopText = new Text("FEDERAL COLLEGE OF EDUCATION(TECH)AKOKA STUDENT UNION\n\t\t\tFECOETSU-ELECTION MANAGER"); scn3TopText.setFont(Font.font("Georgia",FontWeight.BOLD, 15)); String procedure = "Please read carefully;\nPROCEDURE:\n\n 1. Each view allows you to vote for one post\n 2. Every aspirant has a radio button attached to him\n 3. Carefully check the image and the name to be sure\n 4. Check(Click) the Radio Button attached to the ASPIRANT and click Next\n NOTE: You are allowed to vote for "; Text procedureTxt = new Text(procedure); procedureTxt.setFont(Font.font("Comic Sans MS", FontWeight.BOLD, 15)); scn3Top = new HBox(); scn3Top.setId("scn3Top"); scn3Top.getChildren().add(scn3TopText); scn3Top.setAlignment(Pos.CENTER); //Bottom for scene 3 Button goToScene4From3 = new Button("Begin");// Swith to Vote Scene; goToScene4From3.setOnAction( e -> { votePresident();// swithc to reall votin, this lambda was an error }); TilePane bottomTileForScn3 = new TilePane(); bottomTileForScn3.setId("bottomTileForScn3"); bottomTileForScn3.getChildren().addAll(goToScene4From3);// add bootable corp logo and a next button bottomTileForScn3.setAlignment(Pos.CENTER); BorderPane borderScn3 = new BorderPane(); borderScn3.setTop(scn3Top); borderScn3.setBottom(bottomTileForScn3); borderScn3.setCenter(procedureTxt); procedureScene = new Scene(borderScn3, 900, 600); /* ** Commence the vote Scene */ Text scn4TopText = new Text("FEDERAL COLLEGE OF EDUCATION(TECH)AKOKA STUDENT UNION\n\t\t\tFECOETSU-ELECTION MANAGER"); scn4TopText.setFont(Font.font("Georgia", FontWeight.BOLD, 15)); scn4TopText.setId("scn4TopText"); scn4Top = new HBox(); scn4Top.setId("scn4Top"); scn4Top.setAlignment(Pos.CENTER); scn4Top.getChildren().add(scn4TopText); Image doug = new Image("file:C:\\Users\\DANNY\\Desktop\\Vote\\images\\doug.jpg"); Image linus = new Image("file:C:\\Users\\DANNY\\Desktop\\Vote\\images\\linus.jpg"); ImageView president1 = new ImageView(doug); president1.setFitWidth(150); president1.setFitHeight(150); RadioButton radioPresident1 = new RadioButton("Select to vote for DougMamilor"); radioPresident1.setToggleGroup(togglePresi); ImageView president2 = new ImageView(linus); president2.setFitWidth(150); president2.setFitHeight(150); RadioButton radioPresident2 = new RadioButton("Select to vote for LinusTovarld"); radioPresident2.setToggleGroup(togglePresi); ToggleGroup togglePresi = new ToggleGroup(); String tt = "Hi guys, This is a demo, \n Right here and now we are voting for the\n Smartest developer\n LINUS or DOUG"; Text voteInfo = new Text(tt); voteInfo.setFont(Font.font("Lucida Calligraphy", FontWeight.BOLD, 15)); TilePane bottomTileForScn4 = new TilePane(); bottomTileForScn4.setId("bottomTileForScn4"); bottomTileForScn4.setAlignment(Pos.CENTER); //bottomTileForScn4.getChildren().addAll(); String aboutHoverMessage = "Click here to read about this aspirant"; Button about1 = new Button(); about1.setId("about1"); about1.setText("About"); about1.setOnAction( e -> { aboutPresident1(); } ); Button about2 = new Button();// Not declared oustide method yet about2.setId("about2"); about2.setText("About"); Button voteButton = new Button("Vote"); //voteButton.setToolTipText("Click here to vote"); GridPane holdAspirantImage = new GridPane(); holdAspirantImage.setId("holdAspirantImage"); holdAspirantImage.setHgap(10); holdAspirantImage.setVgap(5); holdAspirantImage.setAlignment(Pos.CENTER); holdAspirantImage.add(voteInfo,0,0,2,1); holdAspirantImage.add(president1, 0, 1); holdAspirantImage.add(president2, 1, 1); holdAspirantImage.add(radioPresident1, 0,2); holdAspirantImage.add(about1,0,3); holdAspirantImage.add(radioPresident2,1,2); holdAspirantImage.add(about2,1,3); BorderPane borderScn4 = new BorderPane(); borderScn4.setTop(scn4Top); borderScn4.setBottom(bottomTileForScn4); borderScn4.setCenter(holdAspirantImage); votePresidentCan = new Scene(borderScn4, 900, 600); // DELETE ALL THESE accreditScene.getStylesheets().add(VoteMain.class.getResource("VoteMain.css").toExternalForm()); voteScene.getStylesheets().add(VoteMain.class.getResource("VoteMain.css").toExternalForm()); procedureScene.getStylesheets().add(VoteMain.class.getResource("VoteMain.css").toExternalForm()); votePresidentCan.getStylesheets().add(VoteMain.class.getResource("VoteMain.css").toExternalForm()); } private void switchToTermsAndCond(){// handler for scene one to scene 2 stage.setScene(voteScene); } private void switchToProcedures(){ stage.setScene(procedureScene); } private void votePresident(){ stage.setScene(votePresidentCan); } private void aboutPresident1(){ String abt = "Doug Mamilor is a Serial Programmer and a Technology Entreprenuer\nHe has been on several cutting edge software development projects\nthat has revolutionised the country's economy immensely\nPart of such projects are\n1. Payment aggregator, for the Nigerian Stock exchange\n2. GTBank Online Banking\n\n Douglas is also a Co-Founder at two Key Software development companies in the country: Namely;\nRightclick LTD\nCreative Fractals\n\n *He is currently working with Daniel Osineye on a revolutionary Operating System Called HOLY\nThis O.S is targeting young computer users and it restrict Explicit contents\nmore at bootable.com"; JOptionPane.showMessageDialog(null,abt, "ABOUT DOUG-MAMILOR", JOptionPane.INFORMATION_MESSAGE); }}