Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jFrame;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Font;
- import java.awt.GridLayout;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.BorderFactory;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JTextField;
- import javax.swing.border.Border;
- public class Frame extends JFrame implements ActionListener {
- int cash = 0;
- private static final long serialVersionUID = 1L;
- //default serial version ID no idea what it does but I think i need it???
- public static void main(String[] args) {
- new Frame().setVisible(true);
- }
- public int getStartingAmmt() {
- int amnt = 200;
- return amnt;
- }
- public Frame() {
- super("Trash"); // title of tab thing
- setSize (800 ,600);
- setResizable(false);
- setDefaultCloseOperation(EXIT_ON_CLOSE); // default stuff
- //home screen stuff
- JPanel MainPanel = new JPanel();
- MainPanel.setSize(800, 600);
- MainPanel.setLocation(0, 0);
- MainPanel.setLayout(null);
- MainPanel.setBackground(Color.LIGHT_GRAY);
- this.getContentPane().add(MainPanel);
- JLabel title = new JLabel("Trash", JLabel.CENTER);
- title.setSize(150,70);
- title.setLocation(320,110); // i hate coordinates
- title.setFont(new Font("Serif", Font.PLAIN, 30));
- MainPanel.add (title);
- JButton instruction = new JButton("Instructions");
- instruction.setActionCommand("goInstructions");
- instruction.addActionListener(this);
- instruction.setSize(120,20);
- instruction.setLocation(335,350);
- MainPanel.add (instruction);
- JButton close = new JButton("Exit");
- close.setActionCommand("quit");
- close.addActionListener(this);
- close.setSize(120,20);
- close.setLocation(335,400);
- MainPanel.add (close);
- }
- //action listener stuff
- @Override //implemented from action listener
- public void actionPerformed(ActionEvent e) {
- String name = e.getActionCommand();
- //play
- //help
- if (name.equals("goInstructions")) {
- Container containI;
- containI = getContentPane();
- containI.removeAll();
- System.out.println("Instructions."); //debug
- JPanel InstructionPanel = new JPanel();
- InstructionPanel.setSize(800, 600);
- InstructionPanel.setLocation(0, 0);
- InstructionPanel.setLayout(null);
- InstructionPanel.setBackground(Color.LIGHT_GRAY);
- containI.add(InstructionPanel);
- setVisible(true);
- JLabel instructionTitle = new JLabel("Instructions");
- instructionTitle.setSize(140,40);
- instructionTitle.setLocation(320,70);
- instructionTitle.setFont(new Font("Serif", Font.PLAIN, 30));
- InstructionPanel.add (instructionTitle);
- JLabel i1 = new JLabel("Premise");
- i1.setSize(140,40);
- i1.setLocation(40,120);
- i1.setFont(new Font("Serif", Font.PLAIN, 16));
- InstructionPanel.add (i1);
- 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");
- i2.setSize(700,40);
- i2.setLocation(40,140);
- i2.setFont(new Font("Serif", Font.PLAIN, 14));
- InstructionPanel.add (i2);
- JLabel i2a = new JLabel("going over 21");
- i2a.setSize(700,40);
- i2a.setLocation(40,155);
- i2a.setFont(new Font("Serif", Font.PLAIN, 14));
- InstructionPanel.add (i2a);
- JLabel i3 = new JLabel("Values");
- i3.setSize(140,40);
- i3.setLocation(40,195);
- i3.setFont(new Font("Serif", Font.PLAIN, 16));
- InstructionPanel.add (i3);
- //exit
- else if (name.equals("quit")) {
- dispose(); //does what it sounds
- }
- else if (name.equals("back")) {
- Container containSBack;
- JPanel MainPanel = new JPanel();
- MainPanel.setSize(800, 600);
- MainPanel.setLocation(0, 0);
- MainPanel.setLayout(null);
- MainPanel.setBackground(Color.LIGHT_GRAY);
- this.getContentPane().add(MainPanel);
- JLabel title = new JLabel("Trash", JLabel.CENTER);
- title.setSize(150,70);
- title.setLocation(320,110);
- title.setFont(new Font("Serif", Font.PLAIN, 30));
- MainPanel.add (title);
- JButton instruction = new JButton("Instructions");
- instruction.setActionCommand("goInstructions");
- instruction.addActionListener(this);
- instruction.setSize(120,20);
- instruction.setLocation(335,350);
- MainPanel.add (instruction);
- JButton close = new JButton("Exit");
- close.setActionCommand("quit");
- close.addActionListener(this);
- close.setSize(120,20);
- close.setLocation(335,400);
- MainPanel.add (close);
- containSBack = getContentPane();
- containSBack.removeAll();
- containSBack.add(MainPanel);
- setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement