Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- /*
- * Created by JFormDesigner on Sat May 23 19:28:49 BST 2020
- */
- /**
- * @author Nathan
- */
- public class Potatogui extends JFrame {
- private main ctx;
- private void button1ActionPerformed(ActionEvent e) {
- ctx.setScriptStarted(true);
- this.setVisible(false);
- ctx.ScriptType = ScriptType();
- ctx.timeBegan = System.currentTimeMillis();
- }
- public Potatogui(main main) {
- this.ctx = main;
- initComponents();
- }
- private void initComponents() {
- button1 = new JButton();
- comboBox1 = new JComboBox<>();
- Text = new JLabel();
- //======== this ========
- setTitle("Jueixs Potatos");
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //---- button1 ----
- button1.setText("Start script");
- button1.addActionListener(e -> button1ActionPerformed(e));
- contentPane.add(button1);
- button1.setBounds(new Rectangle(new Point(5, 65), button1.getPreferredSize()));
- //---- comboBox1 ----
- comboBox1.setModel(new DefaultComboBoxModel<>(new String[] {
- "Butter creator",
- "Baked potato",
- "Potato with butter"
- }));
- contentPane.add(comboBox1);
- comboBox1.setBounds(new Rectangle(new Point(5, 35), comboBox1.getPreferredSize()));
- //---- Text ----
- Text.setText("What would you bot?");
- Text.setFont(Text.getFont().deriveFont(Text.getFont().getSize() + 6f));
- contentPane.add(Text);
- Text.setBounds(new Rectangle(new Point(5, 5), Text.getPreferredSize()));
- {
- // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPane.getComponentCount(); i++) {
- Rectangle bounds = contentPane.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = contentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- contentPane.setMinimumSize(preferredSize);
- contentPane.setPreferredSize(preferredSize);
- }
- pack();
- setLocationRelativeTo(getOwner());
- }
- public String ScriptType() {
- return comboBox1.getSelectedItem().toString();
- }
- private JButton button1;
- private JComboBox<String> comboBox1;
- private JLabel Text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement