-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaesar_Cipher.java
More file actions
127 lines (95 loc) · 3.21 KB
/
Copy pathCaesar_Cipher.java
File metadata and controls
127 lines (95 loc) · 3.21 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* Raynier Leroux
* Caesar Cipher
*
*/
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Caesar_Cipher extends Encript{
public static void main(String[] args) {
CaesarSalad();
}
public static void CaesarSalad() {
//Font LabelFont = new Font("SansSerif", Font.PLAIN, 30);
JFrame CaesarsHead = new JFrame();
Caesar_GUI(CaesarsHead);
CaesarsHead.setVisible(true);
CaesarsHead.setSize(1800,500);
// Setting location relavtive to users screen size
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
CaesarsHead.setLocation(dim.width/2-CaesarsHead.getSize().width/2, dim.height/2-CaesarsHead.getSize().height/2);
CaesarsHead.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
CaesarsHead.setResizable(false);
// Icon Retrieving and Setting
ImageIcon img = new ImageIcon("D:\\Eclipse\\Caesar Cipher//Dressing.jpg");
CaesarsHead.setIconImage(img.getImage());
CaesarsHead.setTitle("Caesar Cipher");
CaesarsHead.getContentPane().setBackground(Color.WHITE);
CaesarsHead.getContentPane();
}
/**
* @param F
*/
public static void Caesar_GUI(JFrame F){
JTextField input, output, Shift;
JButton E,D;
//Fonts
Font font1 = new Font("SansSerif", Font.PLAIN, 30 );
// .setBounds( x , y , Width , Height)
F.setLayout(null);
//input Text box
input = new JTextField(30);
input.setBounds(300,15,1300,100);
input.setFont(font1);
F.add(input);
// Shift text box
Shift = new JTextField(10);
Shift.setBounds(215,203,45,80);
Shift.setFont(font1);
F.add(Shift);
// Encripyt Textbox
output = new JTextField(30);
output.setBounds(300,200,1300,100);
output.setFont(font1);
F.add(output);
//Encripyt Button
E = new JButton("Encripyt");
E.setBounds(300,120,650,70);
E.setFont(font1);
E.addActionListener(new ActionListener() {
// ACTIONS when Encrypt button is clicked
@Override
public void actionPerformed(ActionEvent e) {
if(output.getText() != null) {
Shift.setText(null);
output.setText(null);
} // END IF
Shift.setText(String.valueOf(shift));
Encript.Encription(input.getText());
output.setText(EString.toUpperCase());
input.setText(null);
}
});
F.add(E);
//Decrypt Button
D = new JButton("Decrypt");
D.setBounds(949,120,650,70);
D.setFont(font1);
D.addActionListener(new ActionListener(){
// ACTIONS when Encripyt button is clicked
@Override
public void actionPerformed(ActionEvent e) {
output.setText(null);
output.setText(Decypt.Decryption(input.getText(),Shift.getText()));
}
});
F.add(D);
}
}