Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. package jFrame;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.Container;
  6. import java.awt.Font;
  7. import java.awt.GridLayout;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10.  
  11. import javax.swing.BorderFactory;
  12. import javax.swing.JButton;
  13. import javax.swing.JCheckBox;
  14. import javax.swing.JFrame;
  15. import javax.swing.JLabel;
  16. import javax.swing.JPanel;
  17. import javax.swing.JTextField;
  18. import javax.swing.border.Border;
  19.  
  20. public class Frame extends JFrame implements ActionListener {
  21.  
  22. int cash = 0;
  23.  
  24. private static final long serialVersionUID = 1L;
  25. //default serial version ID no idea what it does but I think i need it???
  26.  
  27. public static void main(String[] args) {
  28. new Frame().setVisible(true);
  29. }
  30.  
  31. public int getStartingAmmt() {
  32. int amnt = 200;
  33. return amnt;
  34. }
  35.  
  36. public Frame() {
  37. super("Trash"); // title of tab thing
  38. setSize (800 ,600);
  39. setResizable(false);
  40. setDefaultCloseOperation(EXIT_ON_CLOSE); // default stuff
  41. //home screen stuff
  42.  
  43. JPanel MainPanel = new JPanel();
  44. MainPanel.setSize(800, 600);
  45. MainPanel.setLocation(0, 0);
  46. MainPanel.setLayout(null);
  47. MainPanel.setBackground(Color.LIGHT_GRAY);
  48. this.getContentPane().add(MainPanel);
  49.  
  50. JLabel title = new JLabel("Trash", JLabel.CENTER);
  51. title.setSize(150,70);
  52. title.setLocation(320,110); // i hate coordinates
  53. title.setFont(new Font("Serif", Font.PLAIN, 30));
  54. MainPanel.add (title);
  55.  
  56. JButton instruction = new JButton("Instructions");
  57. instruction.setActionCommand("goInstructions");
  58. instruction.addActionListener(this);
  59. instruction.setSize(120,20);
  60. instruction.setLocation(335,350);
  61. MainPanel.add (instruction);
  62.  
  63. JButton close = new JButton("Exit");
  64. close.setActionCommand("quit");
  65. close.addActionListener(this);
  66. close.setSize(120,20);
  67. close.setLocation(335,400);
  68. MainPanel.add (close);
  69.  
  70. }
  71.  
  72. //action listener stuff
  73.  
  74. @Override //implemented from action listener
  75. public void actionPerformed(ActionEvent e) {
  76. String name = e.getActionCommand();
  77.  
  78. //play
  79.  
  80. //help
  81. if (name.equals("goInstructions")) {
  82.  
  83. Container containI;
  84. containI = getContentPane();
  85. containI.removeAll();
  86. System.out.println("Instructions."); //debug
  87. JPanel InstructionPanel = new JPanel();
  88. InstructionPanel.setSize(800, 600);
  89. InstructionPanel.setLocation(0, 0);
  90. InstructionPanel.setLayout(null);
  91. InstructionPanel.setBackground(Color.LIGHT_GRAY);
  92. containI.add(InstructionPanel);
  93. setVisible(true);
  94.  
  95. JLabel instructionTitle = new JLabel("Instructions");
  96. instructionTitle.setSize(140,40);
  97. instructionTitle.setLocation(320,70);
  98. instructionTitle.setFont(new Font("Serif", Font.PLAIN, 30));
  99. InstructionPanel.add (instructionTitle);
  100.  
  101. JLabel i1 = new JLabel("Premise");
  102. i1.setSize(140,40);
  103. i1.setLocation(40,120);
  104. i1.setFont(new Font("Serif", Font.PLAIN, 16));
  105. InstructionPanel.add (i1);
  106.  
  107. JLabel i2 = new JLabel("The basic premise of the game is that you want to have a hand value that is closer to 21 than that of the dealer, without");
  108. i2.setSize(700,40);
  109. i2.setLocation(40,140);
  110. i2.setFont(new Font("Serif", Font.PLAIN, 14));
  111. InstructionPanel.add (i2);
  112.  
  113. JLabel i2a = new JLabel("going over 21");
  114. i2a.setSize(700,40);
  115. i2a.setLocation(40,155);
  116. i2a.setFont(new Font("Serif", Font.PLAIN, 14));
  117. InstructionPanel.add (i2a);
  118.  
  119. JLabel i3 = new JLabel("Values");
  120. i3.setSize(140,40);
  121. i3.setLocation(40,195);
  122. i3.setFont(new Font("Serif", Font.PLAIN, 16));
  123. InstructionPanel.add (i3);
  124.  
  125.  
  126. //exit
  127.  
  128. else if (name.equals("quit")) {
  129. dispose(); //does what it sounds
  130. }
  131.  
  132. else if (name.equals("back")) {
  133. Container containSBack;
  134.  
  135. JPanel MainPanel = new JPanel();
  136. MainPanel.setSize(800, 600);
  137. MainPanel.setLocation(0, 0);
  138. MainPanel.setLayout(null);
  139. MainPanel.setBackground(Color.LIGHT_GRAY);
  140. this.getContentPane().add(MainPanel);
  141.  
  142. JLabel title = new JLabel("Trash", JLabel.CENTER);
  143. title.setSize(150,70);
  144. title.setLocation(320,110);
  145. title.setFont(new Font("Serif", Font.PLAIN, 30));
  146. MainPanel.add (title);
  147.  
  148. JButton instruction = new JButton("Instructions");
  149. instruction.setActionCommand("goInstructions");
  150. instruction.addActionListener(this);
  151. instruction.setSize(120,20);
  152. instruction.setLocation(335,350);
  153. MainPanel.add (instruction);
  154.  
  155. JButton close = new JButton("Exit");
  156. close.setActionCommand("quit");
  157. close.addActionListener(this);
  158. close.setSize(120,20);
  159. close.setLocation(335,400);
  160. MainPanel.add (close);
  161.  
  162. containSBack = getContentPane();
  163. containSBack.removeAll();
  164. containSBack.add(MainPanel);
  165. setVisible(true);
  166.  
  167. }
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement