
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author James
 */
public class PunchCount {
    
    private int userTime = 10;
    private int thresh = 250;
    private int MINIMUM = 10;
    private int MAXIMUM = 10000;
    private int STEP = 5;
    public PunchCount(JFrame frame){
        
        ////Initializing panels and other variables//////
        JPanel main = new JPanel(new GridBagLayout());
        JPanel q1 = new JPanel(new GridBagLayout());
        JPanel q2 = new JPanel(new GridBagLayout());
        JPanel q3 = new JPanel(new GridBagLayout());
        JPanel q4 = new JPanel(new GridBagLayout());
        JPanel q5 = new JPanel(new GridBagLayout());
        JPanel q6 = new JPanel(new GridBagLayout());
        JPanel q7 = new JPanel(new GridBagLayout());
        GridBagConstraints gc = new GridBagConstraints();
        
        JLabel title = new JLabel("Punch Count");
        JLabel punchCount = new JLabel("Punch Count");
        JLabel numPunch = new JLabel("20");
        JLabel timeSetting = new JLabel("Time Setting (Seconds)");
        JLabel time = new JLabel("Time");
        JLabel countingTime = new JLabel("10");
        countingTime.setBorder(BorderFactory.createLineBorder(Color.black));
        JLabel threshold = new JLabel("Threshold Force (lbs)");
        JLabel hit = new JLabel("Last Hit");
        JLabel hitRecount = new JLabel("500");
        hitRecount.setBorder(BorderFactory.createLineBorder(Color.black));
        JButton history = new JButton("History");
        JLabel up = new JLabel("up");
        JButton home = new JButton("Home");
        JButton start = new JButton("Start");
        start.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        JButton pause = new JButton("Pause");
        JButton stop = new JButton("Stop");
        JSpinner timeSpinner = new JSpinner(new SpinnerNumberModel(userTime,MINIMUM,MAXIMUM,STEP));
        JSpinner thresholdForce = new JSpinner(new SpinnerNumberModel(thresh,1,1000,STEP));
        /////Finish initializing panels and other variables/////
        
        
        /////Adding components to subpanels/////
        ////Creating the top banner of page//////
        gc.anchor = GridBagConstraints.FIRST_LINE_START;
        q1.add(title,gc);
        gc.anchor = GridBagConstraints.FIRST_LINE_END;
        q1.add(punchCount,gc);
        gc.anchor = GridBagConstraints.LINE_END;
        gc.weighty = 1;
        q1.add(numPunch,gc);
        /////End of creating top banner of page//////
        
        /////Creating left top middle half/////
        gc.anchor = GridBagConstraints.CENTER;
        q2.add(timeSetting,gc);
        gc.anchor = GridBagConstraints.PAGE_END;
        gc.weighty = 4;
        q2.add(timeSpinner,gc);
        ////End of creating left top middle half////
        
        ////Creating left bot middle half/////
        gc.anchor = GridBagConstraints.CENTER;
        gc.weighty = 1;
        q6.add(threshold,gc);
        gc.anchor = GridBagConstraints.PAGE_END;
        gc.weighty = 4;
        q6.add(thresholdForce,gc);
        /////End of creating left bot middle half/////
        
        ////Creating Right Top Middle half/////
        gc.anchor = GridBagConstraints.LINE_END;
        gc.weighty = .5;
        q3.add(time,gc);
        gc.anchor = GridBagConstraints.LAST_LINE_END;
        gc.weighty = 2;
        q3.add(countingTime,gc);
        ////End of creating right top middle half/////
        
        ////Creating right bot Middle half/////
        gc.anchor = GridBagConstraints.LINE_END;
        gc.weighty = 0.5;
        q7.add(hit,gc);
        gc.anchor = GridBagConstraints.LAST_LINE_END;
        gc.weighty = 4;
        q7.add(hitRecount,gc);
        ////End of creating right bot Middle half/////
        
        ////Creating left bottom half//////
        gc.gridx = 0;
        gc.gridy = 0;
        q4.add(history,gc);
        gc.gridx = 1;
        q4.add(home,gc);
        /////End of creating left bottom half/////
        
        /////Creating right bottom half////
        gc.gridx = 0;
        q5.add(start,gc);
        gc.gridx = 1;
        q5.add(pause,gc);
        gc.gridx = 2;
        q5.add(stop,gc);
        /////End of creating right bottom half/////
        ////Finish adding components to subpanels/////
        
        /////Adding subpanels to main panel/////
        gc.gridx = 0;
        gc.gridy = 0;
        gc.weightx = 1;
        gc.weighty = 1;
        main.add(q1,gc);
        
        gc.gridy = 1;
        gc.weightx = 1;
        gc.weighty = 1;
        main.add(q2,gc);
        
        gc.gridx = 1;
        main.add(q3,gc);
        
        gc.gridx = 0;
        gc.gridy = 2;
        main.add(q6,gc);
        
        gc.gridx = 1;
        main.add(q7,gc);
        
        gc.gridx = 0;
        gc.gridy = 3;
        gc.weighty = 1;
        main.add(q4,gc);
        
        gc.gridx = 1;
        main.add(q5,gc);
        /////Finish adding subpanels to main panel/////
        
        frame.getContentPane().add(main);
    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        Main.swap(0);
    }
}
