-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavafx.java
101 lines (75 loc) · 3.11 KB
/
Javafx.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
Carmine Attanasio
Caser Cipher GUI
*/
package caeser.cipher;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class CaeserCipher extends Application {
//declaration of controls
TextField tfPlainTxt = new TextField();
TextField tfShift = new TextField();
//button to encrypt text
private Button btnEncrypt;
//Labels for app
private Label lblHeader;
private Label lblPlaintxt;
private Label lblencryptedtxt;
private Label lblDescription;
//vbox for layout of items
private VBox vBoxInput;
private VBox vBoxOutput;
//creates JavaFX
@Override
public void start(Stage primaryStage) {
//header to describe function of program to user
lblHeader = new Label("Encrypt your text using the caeser cipher");
lblHeader.setMinWidth(350);
lblHeader.setAlignment(Pos.CENTER);
lblHeader.setStyle("-fx-font-family: 'Comic Sans MS'; -fx-font-size: 28px; -fx-text-fill: white; -fx-background-color: rgb(104, 50, 0); -fx-font-weight: bold;");
//initiates labels
lblPlaintxt= new Label ("Enter plain text to be encrypted");
lblPlaintxt.setStyle("-fx-font-family: 'Comic Sans MS'; -fx-font-size: 14px; -fx-text-fill: black; -fx-background-color:#FFF8DC); -fx-font-weight: bold;");
lblencryptedtxt = new Label("");
lblDescription = new Label("Plain text is encrypted using caser cipher and shift key input");
//creates encrypt button
btnEncrypt = new Button("Encrypt Text");
btnEncrypt.setStyle("-fx-text-fill: white; -fx-background-color: tan; -fx-font-weight: bold;");
//makes vbox for input
vBoxInput = new VBox(30,lblPlaintxt, tfPlainTxt, btnEncrypt);
//create vbox for results
vBoxOutput = new VBox(50,lblDescription, lblDescription);
vBoxOutput.setPrefWidth(140);
vBoxOutput.setPrefHeight(270);
vBoxOutput.setPadding( new Insets(10) );
vBoxOutput.setStyle("-fx-background-color: lightblue; -fx-border-color: black; -fx-border-radius: 10;");
GridPane grid = new GridPane();
grid.addRow(0, lblHeader);
GridPane.setColumnSpan(lblHeader, 2);
GridPane.setHalignment(lblHeader, HPos.CENTER);
grid.addRow(1, vBoxInput, vBoxOutput);
Scene scene = new Scene(grid, 500, 310);
primaryStage.setTitle("Find Prime Factors");
primaryStage.setResizable(false);
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}