Package com.fiveht.tick.ui

Source Code of com.fiveht.tick.ui.View

/*
* 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;

import com.fiveht.tick.ui.event.ExitEvent;
import com.fiveht.tick.ui.event.ExitListener;
import com.fiveht.tick.ui.view.TimerScrollPane;
import java.awt.BorderLayout;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.event.EventListenerList;

/**
* This class represents the actual view of the application. As a panel, it
* it intended to be embeddable into all implementations of Tick Java Desktop,
* be it desktop application, webstart, or applet.
* <p>
* An important point to remember is that although this is a JPanel, it contains
* a UIRoot reference to the parent so that this class can add menus.
*
* @author Nathan Crause
*/
public class View extends JPanel {
   
    private UIRoot parent;

    public View(UIRoot parent) {
        super(new BorderLayout());
       
        this.parent = parent;
       
        init();
    }
   
    private TimerScrollPane scrollPane;

    private void init() {
        parent.setJMenuBar(new MenuBar(this));
       
        add(new ToolBar(this), BorderLayout.NORTH);
        add(scrollPane = new TimerScrollPane(), BorderLayout.CENTER);
    }

    public TimerScrollPane getScrollPane() {
        return scrollPane;
    }
   
    private EventListenerList listeners = new EventListenerList();
   
    public void addExitListener(ExitListener l) {
        listeners.add(ExitListener.class, l);
    }
   
    public void removeExitListener(ExitListener l) {
        listeners.remove(ExitListener.class, l);
    }
   
    public void fireExit(ExitEvent event) {
        // pack the listeners into a list
        List<ExitListener> list = Arrays.asList(listeners.getListeners(ExitListener.class));
        // reverse the order run the last first
        Collections.reverse(list);
       
        // loop through them all
        for (ExitListener l : list) {
            l.exitSelected(event);
        }
    }
   
}
TOP

Related Classes of com.fiveht.tick.ui.View

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.