Package com.fiveht.tick.ui.view

Source Code of com.fiveht.tick.ui.view.TimerPanel

/*
* Copyright (C) 2012 FiveHT Media Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package com.fiveht.tick.ui.view;

import com.fiveht.tick.ui.view.timer.CloseButton;
import com.fiveht.tick.ui.view.timer.PlayButton;
import com.fiveht.tick.ui.view.timer.RecordButton;
import com.fiveht.tick.ui.view.timer.RecycleButton;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFormattedTextField;
import javax.swing.JPanel;
import javax.swing.text.MaskFormatter;

/**
*
* @author Nathan Crause
*/
public class TimerPanel extends JPanel {

    public TimerPanel() {
        super(new GridBagLayout());
       
        init();
    }
   
    private JFormattedTextField timeField;

    private void init() {
        try {
            MaskFormatter fmt = new MaskFormatter("##:##:##:##");
            Font fnt = new Font(Font.MONOSPACED, Font.BOLD, 24);
           
            fmt.setPlaceholderCharacter('0');
            timeField = new JFormattedTextField(fmt);
           
            timeField.setFont(fnt);
           
            add(new RecycleButton(this), new GridBagConstraints(0, 0, 1, 1, 0.0d, 1.0d, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            add(timeField, new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 1.0d, 1.0d, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            add(new PlayButton(this), new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0.0d, 1.0d, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            add(new RecordButton(this), new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0.0d, 1.0d, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            add(new CloseButton(this), new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 0.0d, 1.0d, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        } catch (ParseException ex) {
            Logger.getLogger(TimerPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
   
    public String getTime() {
        return (String) timeField.getValue();
    }
   
    public void setTime(String value) {
        timeField.setValue(value);
    }
   
}
TOP

Related Classes of com.fiveht.tick.ui.view.TimerPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.