Advertisement
Guest User

Jueix's potatos v2 gui script

a guest
May 23rd, 2020
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. /*
  5. * Created by JFormDesigner on Sat May 23 19:28:49 BST 2020
  6. */
  7.  
  8.  
  9.  
  10. /**
  11. * @author Nathan
  12. */
  13. public class Potatogui extends JFrame {
  14.  
  15. private main ctx;
  16. private void button1ActionPerformed(ActionEvent e) {
  17. ctx.setScriptStarted(true);
  18. this.setVisible(false);
  19. ctx.ScriptType = ScriptType();
  20. ctx.timeBegan = System.currentTimeMillis();
  21. }
  22.  
  23. public Potatogui(main main) {
  24. this.ctx = main;
  25. initComponents();
  26. }
  27.  
  28. private void initComponents() {
  29. button1 = new JButton();
  30. comboBox1 = new JComboBox<>();
  31. Text = new JLabel();
  32.  
  33. //======== this ========
  34. setTitle("Jueixs Potatos");
  35. Container contentPane = getContentPane();
  36. contentPane.setLayout(null);
  37.  
  38. //---- button1 ----
  39. button1.setText("Start script");
  40. button1.addActionListener(e -> button1ActionPerformed(e));
  41. contentPane.add(button1);
  42. button1.setBounds(new Rectangle(new Point(5, 65), button1.getPreferredSize()));
  43.  
  44. //---- comboBox1 ----
  45. comboBox1.setModel(new DefaultComboBoxModel<>(new String[] {
  46. "Butter creator",
  47. "Baked potato",
  48. "Potato with butter"
  49. }));
  50. contentPane.add(comboBox1);
  51. comboBox1.setBounds(new Rectangle(new Point(5, 35), comboBox1.getPreferredSize()));
  52.  
  53. //---- Text ----
  54. Text.setText("What would you bot?");
  55. Text.setFont(Text.getFont().deriveFont(Text.getFont().getSize() + 6f));
  56. contentPane.add(Text);
  57. Text.setBounds(new Rectangle(new Point(5, 5), Text.getPreferredSize()));
  58.  
  59. {
  60. // compute preferred size
  61. Dimension preferredSize = new Dimension();
  62. for(int i = 0; i < contentPane.getComponentCount(); i++) {
  63. Rectangle bounds = contentPane.getComponent(i).getBounds();
  64. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  65. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  66. }
  67. Insets insets = contentPane.getInsets();
  68. preferredSize.width += insets.right;
  69. preferredSize.height += insets.bottom;
  70. contentPane.setMinimumSize(preferredSize);
  71. contentPane.setPreferredSize(preferredSize);
  72. }
  73. pack();
  74. setLocationRelativeTo(getOwner());
  75. }
  76.  
  77. public String ScriptType() {
  78. return comboBox1.getSelectedItem().toString();
  79. }
  80.  
  81. private JButton button1;
  82. private JComboBox<String> comboBox1;
  83. private JLabel Text;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement