summaryrefslogtreecommitdiff
path: root/src/Mainframe.java
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2022-04-25 18:43:46 +0200
committerLeonard Kugis <leonard@kug.is>2022-04-25 18:43:46 +0200
commitc9dd9469183d95c6c2f4d01e3d6365ec57386a65 (patch)
tree07ec933179eced02eec8a70f8b64c9281d453457 /src/Mainframe.java
Initial commitHEADmaster
Diffstat (limited to 'src/Mainframe.java')
-rwxr-xr-xsrc/Mainframe.java78
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);
+ }
+
+}