Add basic UI

This commit is contained in:
Christian Loch 2020-05-07 18:24:04 +02:00 committed by Loch Christian (uib05376)
parent 05b8cfa9bc
commit dc3918da66
3 changed files with 237 additions and 9 deletions

View File

@ -1,9 +0,0 @@
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
BigInteger prime = Prime.generate(32);
System.out.println("Finished - number is "+prime);
}
}

171
src/MainWindow.form Normal file
View File

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="MainWindow">
<grid id="cbd77" binding="contentPane" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<xy x="48" y="54" width="720" height="500"/>
</constraints>
<properties/>
<border type="empty">
<size top="10" left="10" bottom="10" right="10"/>
</border>
<children>
<grid id="12135" layout-manager="GridLayoutManager" row-count="9" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints border-constraint="Center"/>
<properties/>
<border type="none"/>
<children>
<component id="adfc7" class="javax.swing.JTextArea" binding="publicKeytextArea">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
<component id="2e5d8" class="javax.swing.JTextArea" binding="privateKeyTextArea">
<constraints>
<grid row="3" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
</constraints>
<properties/>
</component>
<component id="17322" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Public key:"/>
</properties>
</component>
<component id="ffa7c" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Private key:"/>
</properties>
</component>
<component id="4861a" class="javax.swing.JTextField" binding="plainNumber">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="f31a0" class="javax.swing.JTextField" binding="encryptedNumber2">
<constraints>
<grid row="5" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="4096" class="javax.swing.JButton" binding="cryptButton" default-binding="true">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Crypt"/>
</properties>
</component>
<component id="717e0" class="javax.swing.JButton" binding="decryptButton" default-binding="true">
<constraints>
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Decrypt"/>
</properties>
</component>
<component id="7dd2a" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Plain number:"/>
</properties>
</component>
<component id="b4aca" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Encrypted number:"/>
</properties>
</component>
<component id="5d2a6" class="javax.swing.JTextField" binding="encryptedNumber">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="c65b1" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Encrypted number:"/>
</properties>
</component>
<component id="df950" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Decrypted number:"/>
</properties>
</component>
<component id="2a7e2" class="javax.swing.JTextField" binding="decryptedNumber">
<constraints>
<grid row="7" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="bc95a" class="javax.swing.JSlider" binding="keylength">
<constraints>
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<paintTicks value="false"/>
</properties>
<clientProperties>
<JSlider.isFilled class="java.lang.Boolean" value="false"/>
</clientProperties>
</component>
<component id="de444" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Key length:"/>
</properties>
</component>
<component id="aeaa8" class="javax.swing.JButton" binding="generateKeysButton" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Generate keys"/>
</properties>
</component>
<component id="8ead4" class="javax.swing.JLabel" binding="keylengthLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

66
src/MainWindow.java Normal file
View File

@ -0,0 +1,66 @@
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MainWindow extends JDialog implements ChangeListener, ActionListener {
private JPanel contentPane;
private JTextArea publicKeytextArea;
private JTextArea privateKeyTextArea;
private JTextField plainNumber;
private JTextField encryptedNumber2;
private JButton cryptButton;
private JButton decryptButton;
private JButton generateKeysButton;
private JTextField encryptedNumber;
private JTextField decryptedNumber;
private JSlider keylength;
private JLabel keylengthLabel;
private JButton buttonOK;
public MainWindow() {
setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
generateKeysButton.addActionListener(this);
cryptButton.addActionListener(this);
decryptButton.addActionListener(this);
keylength.setMinimum(8);
keylength.setMaximum(64);
keylength.setMajorTickSpacing(10);
keylength.setMinorTickSpacing(5);
keylength.setValue(32);
keylength.setPaintTicks(true);
keylength.setPaintLabels(true);
keylength.addChangeListener(this);
keylengthLabel.setText(String.valueOf(keylength.getValue()));
}
public void stateChanged(ChangeEvent e){
JSlider source = (JSlider)e.getSource();
if (source == this.keylength) {
int value = source.getValue();
this.keylengthLabel.setText(String.valueOf(value));
}
}
public void actionPerformed(ActionEvent e) {
JButton source = (JButton) e.getSource();
if (source == this.cryptButton) {
System.out.println("crypt button clicked!");
} else if (source == this.decryptButton) {
System.out.println("decrypt button clicked!");
} else if (source == this.generateKeysButton) {
System.out.println("Generate button clicked!");
}
}
public static void main(String[] args) {
MainWindow dialog = new MainWindow();
dialog.pack();
dialog.setVisible(true);
dialog.setSize(800, 600);
System.exit(0);
}
}