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
|
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import algorithmus.Algorithmus;
import algorithmus.Autokey;
import algorithmus.Blabla;
import algorithmus.Caesar;
import algorithmus.Case;
import algorithmus.Palisaden;
import algorithmus.Vigenere;
import algorithmus.XOR;
import algorithmus.Zaehlen;
public class Mainframe extends JFrame {
private JTextArea input, output;
private JScrollPane scrollInput, scrollOutput;
private JComboBox combo;
private JButton options, encode, decode;
private Algorithmus[] algo = new Algorithmus[] { new Case(), new Caesar(), new Blabla(), new Zaehlen(), new Vigenere(), new XOR(), new Autokey(), new Palisaden() };
public Mainframe() {
this.setLayout(null);
this.setResizable(false);
this.setTitle("Kryptographie");
this.setSize(500, 500);
input = new JTextArea();
input.setLineWrap(true);
scrollInput = new JScrollPane(input);
scrollInput.setBounds(5, 5, 470, 205);
output = new JTextArea();
output.setEditable(false);
output.setLineWrap(true);
scrollOutput = new JScrollPane(output);
scrollOutput.setBounds(5, 245, 470, 205);
String[] names = new String[algo.length];
for(int i = 0; i<names.length; i++)
names[i] = algo[i].getName();
combo = new JComboBox(names);
combo.setBounds(5, 215, 150, 20);
options = new JButton("Options");
options.setBounds(160, 215, 100, 20);
options.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
algo[combo.getSelectedIndex()].options();
}
});
encode = new JButton("Encode");
encode.setBounds(270, 215, 100, 20);
encode.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
output.setText(algo[combo.getSelectedIndex()].encode(input.getText()));
}
});
decode = new JButton("Decode");
decode.setBounds(375, 215, 100, 20);
decode.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
output.setText(algo[combo.getSelectedIndex()].decode(input.getText()));
}
});
this.getContentPane().add(scrollInput);
this.getContentPane().add(scrollOutput);
this.add(combo);
this.add(encode);
this.add(decode);
this.add(options);
}
}
|