- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCipherGUI.java
More file actions
Latest commit
45 lines (38 loc) · 1.6 KB
/
Copy pathCipherGUI.java
File metadata and controls
45 lines (38 loc) · 1.6 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
importjavax.swing.*;
importjava.awt.*;
publicclassCipherGUI {
publicstaticvoidmain(String[] args) {
JFrameframe = newJFrame("Шифратор v1.0.1");
frame.setLayout(newBoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextFieldinputField = newJTextField();
inputField.setMaximumSize(newDimension(300, 30));
JButtonencryptButton = newJButton("Зашифровать");
JButtondecryptButton = newJButton("Расшифровать");
JLabelresultLabel = newJLabel();
frame.add(Box.createVerticalStrut(10));
frame.add(inputField);
frame.add(Box.createVerticalStrut(10));
JPanelbuttonPanel = newJPanel(newFlowLayout());
buttonPanel.add(encryptButton);
buttonPanel.add(decryptButton);
frame.add(buttonPanel);
frame.add(Box.createVerticalStrut(5));
JPanelresultPanel = newJPanel(newFlowLayout(FlowLayout.CENTER));
resultPanel.add(resultLabel);
frame.add(resultPanel);
frame.add(Box.createVerticalGlue());
encryptButton.addActionListener(e -> {
Stringtext = inputField.getText();
Stringencrypted = Cipher.encrypt(text);
resultLabel.setText(encrypted);
});
decryptButton.addActionListener(e -> {
Stringtext = inputField.getText();
Stringdecrypted = Cipher.decrypt(text);
resultLabel.setText(decrypted);
});
frame.setSize(350, 220);
frame.setVisible(true);
}
}