diff options
Diffstat (limited to 'src/Mainframe.java')
-rwxr-xr-x | src/Mainframe.java | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/Mainframe.java b/src/Mainframe.java new file mode 100755 index 0000000..e486e2a --- /dev/null +++ b/src/Mainframe.java @@ -0,0 +1,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);
+ }
+
+}
|