Java tutorial
/* * 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/>. */ /* * ArffViewer.java * Copyright (C) 2009-2016 University of Waikato, Hamilton, New Zealand * */ package adams.gui.menu; import adams.core.io.PlaceholderFile; import adams.gui.application.AbstractApplicationFrame; import adams.gui.application.ChildFrame; import adams.gui.application.UserMode; import adams.gui.core.GUIHelper; import weka.gui.arffviewer.ArffViewerMainPanel; import javax.swing.JPanel; /** * Opens the ARFF viewer. * * @author fracpete (fracpete at waikato dot ac dot nz) * @version $Revision$ */ public class ArffViewer extends AbstractParameterHandlingWekaMenuItemDefinition { /** for serialization. */ private static final long serialVersionUID = 1279360379007337239L; /** * Initializes the menu item with no owner. */ public ArffViewer() { this(null); } /** * Initializes the menu item. * * @param owner the owning application */ public ArffViewer(AbstractApplicationFrame owner) { super(owner); } /** * Launches the functionality of the menu item. */ public void launch() { JPanel dummy = new JPanel(); ChildFrame frame = createChildFrame(dummy, GUIHelper.getDefaultDialogDimension()); ArffViewerMainPanel panel = new ArffViewerMainPanel(frame); frame.setJMenuBar(panel.getMenu()); dummy.getParent().remove(dummy); frame.getContentPane().add(panel); // load files for (int i = 0; i < m_Parameters.length; i++) panel.loadFile(new PlaceholderFile(m_Parameters[i]).getAbsolutePath()); } /** * Returns the title of the window (and text of menuitem). * * @return the title */ public String getTitle() { return "WEKA Arff Viewer"; } /** * Whether the panel can only be displayed once. * * @return true if the panel can only be displayed once */ public boolean isSingleton() { return false; } /** * Returns the user mode, which determines visibility as well. * * @return the user mode */ public UserMode getUserMode() { return UserMode.BASIC; } /** * Returns the category of the menu item in which it should appear, i.e., * the name of the menu. * * @return the category/menu name */ @Override public String getCategory() { return CATEGORY_TOOLS; } }