/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * pnlDatePicker.java
 *
 * Created on Apr 21, 2010, 10:05:11 PM
 */

package uce.ui.components;

import java.util.Calendar;
import uce.ui.components.jpnCondition.MyTime;

/**
 *
 * @author chepa
 */
public class pnlTimePicker extends javax.swing.JPanel {

    /** Creates new form pnlDatePicker */
    public pnlTimePicker() {
		initComponents();
		Calendar cal = Calendar.getInstance();
		setTime(new MyTime(cal.get(Calendar.HOUR), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND)));
    }

	public pnlTimePicker(MyTime time) {
		initComponents();
		setTime(time);
	}

	public void setTime(MyTime time){
		spnHr.setValue(time.getHours());
		spnMin.setValue(time.getMins());
		spnSec.setValue(time.getSecs());
	}

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        spnHr = new javax.swing.JSpinner();
        jLabel3 = new javax.swing.JLabel();
        spnMin = new javax.swing.JSpinner();
        jLabel4 = new javax.swing.JLabel();
        spnSec = new javax.swing.JSpinner();
        jLabel5 = new javax.swing.JLabel();

        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(400, 22));

        spnHr.setModel(new javax.swing.SpinnerNumberModel(0, 0, 23, 1));
        spnHr.setName("spnHr"); // NOI18N

        jLabel3.setText("Hour(s)"); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        spnMin.setModel(new javax.swing.SpinnerNumberModel(0, 0, 59, 1));
        spnMin.setName("spnMin"); // NOI18N

        jLabel4.setText("Min(s)"); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        spnSec.setModel(new javax.swing.SpinnerNumberModel(0, 0, 59, 1));
        spnSec.setName("spnSec"); // NOI18N

        jLabel5.setText("Second(s)"); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(spnHr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(spnMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(spnSec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(3, 3, 3)
                .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                .addGap(22, 22, 22))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
            .addComponent(spnHr)
            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
            .addComponent(spnMin)
            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
            .addComponent(spnSec)
            .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JSpinner spnHr;
    private javax.swing.JSpinner spnMin;
    private javax.swing.JSpinner spnSec;
    // End of variables declaration//GEN-END:variables

	MyTime m_Time;

	public MyTime getTime() {
		return new MyTime((Integer) spnHr.getValue(), (Integer) spnMin.getValue(), (Integer) spnSec.getValue());
	}
}

