MOA 12.03
Real Time Analytics for Data Streams
GUI.java
Go to the documentation of this file.
00001 /*
00002  *    GUI.java
00003  *    Copyright (C) 2010 University of Waikato, Hamilton, New Zealand
00004  *    @author Albert Bifet (abifet at cs dot waikato dot ac dot nz)
00005  *    @author FracPete (fracpete at waikato dot ac dot nz)
00006  *
00007  *    This program is free software; you can redistribute it and/or modify
00008  *    it under the terms of the GNU General Public License as published by
00009  *    the Free Software Foundation; either version 3 of the License, or
00010  *    (at your option) any later version.
00011  *
00012  *    This program is distributed in the hope that it will be useful,
00013  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *    GNU General Public License for more details.
00016  *
00017  *    You should have received a copy of the GNU General Public License
00018  *    along with this program. If not, see <http://www.gnu.org/licenses/>.
00019  *    
00020  */
00021 package moa.gui;
00022 
00023 import java.awt.BorderLayout;
00024 
00025 import javax.swing.JFrame;
00026 import javax.swing.JPanel;
00027 
00028 import moa.DoTask;
00029 
00038 public class GUI extends JPanel {
00039 
00040     private static final long serialVersionUID = 1L;
00041 
00042     private javax.swing.JTabbedPane panel;
00043 
00044     public GUI() {
00045         initGUI();
00046     }
00047 
00048     private void initGUI() {
00049         setLayout(new BorderLayout());
00050 
00051         // Create and set up tabs
00052         panel = new javax.swing.JTabbedPane();
00053         add(panel, BorderLayout.CENTER);
00054 
00055         // initialize additional panels
00056         String[] tabs = GUIDefaults.getTabs();
00057         for (int i = 0; i < tabs.length; i++) {
00058             try {
00059                 // determine classname
00060                 String[] optionsStr = tabs[i].split(":");
00061                 String classname = optionsStr[0];
00062                 // setup panel
00063                 AbstractTabPanel tabPanel = (AbstractTabPanel) Class.forName(classname).newInstance();
00064                 panel.addTab(tabPanel.getTabTitle(), null, (JPanel) tabPanel, tabPanel.getDescription());
00065             } catch (Exception e) {
00066                 e.printStackTrace();
00067             }
00068         }
00069 
00070     }
00071 
00072     public static void main(String[] args) {
00073         try {
00074             if (DoTask.isJavaVersionOK() == false || DoTask.isWekaVersionOK() == false) {
00075                 return;
00076             }
00077             javax.swing.SwingUtilities.invokeLater(new Runnable() {
00078 
00079                 @Override
00080                 public void run() {
00081                     // Create and set up the window.
00082                     JFrame frame = new JFrame("MOA Graphical User Interface");
00083                     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
00084 
00085                     try {
00086                         javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
00087                     } catch (Exception e) {
00088                     }
00089 
00090                     GUI gui = new GUI();
00091                     frame.getContentPane().setLayout(new BorderLayout());
00092                     frame.getContentPane().add(gui);
00093 
00094                     // Display the window.
00095                     frame.pack();
00096                     frame.setVisible(true);
00097                 }
00098             });
00099         } catch (Exception e) {
00100             e.printStackTrace();
00101         }
00102     }
00103 }
 All Classes Namespaces Files Functions Variables Enumerations