📄 optionsdialog.java
字号:
/* * $RCSfile: OptionsDialog.java,v $ * $Revision: 1.7 $ * $Date: 2005/04/25 01:26:31 $ * * NeuralNetworkToolkit * Copyright (C) 2004 Universidade de Brasília * * This file is part of NeuralNetworkToolkit. * * NeuralNetworkToolkit 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 2 of the License, or * (at your option) any later version. * * NeuralNetworkToolkit 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 NeuralNetworkToolkit; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 - USA. */package neuralnetworktoolkit.gui.options;import java.util.ResourceBundle;import javax.swing.*;import neuralnetworktoolkit.architectures.ArchitectureParameters;import neuralnetworktoolkit.gui.options.architecture.ArchitecturePanel;import neuralnetworktoolkit.gui.options.method.TrainingMethodPanel;import neuralnetworktoolkit.gui.options.normalization.NormalizationPanel;import neuralnetworktoolkit.methods.TrainingParameters;import neuralnetworktoolkit.normalization.NormalizationParameters;/** * Options dialog box. * * @version $Revision: 1.7 $ - $Date: 2005/04/25 01:26:31 $ * * @author <a href="mailto:rodbra@pop.com.br">Rodrigo C. M. Coimbra</a> * @author <a href="mailto:hugoiver@yahoo.com.br">Hugo Iver V. Gonçalves</a> */public class OptionsDialog { private static final int OK_BUTTON = 0; private static final int CANCEL_BUTTON = 1; private String frameTitle; private Object[] dialogItems; private String[] options; private JTabbedPane optionsTab; private ArchitecturePanel architecturePanel; private TrainingMethodPanel trainingMethodPanel; private NormalizationPanel normalizationPanel; private ArchitectureParameters parameters; private TrainingParameters trainingParameters; private NormalizationParameters normalizationParameters; private ResourceBundle resource; /** * * @param architecture * @param trainingMethod * @param architectureParameters * @param trainingParameters * @param normalizationParameters * @throws OptionsDialogException */ public OptionsDialog(String architecture, String trainingMethod, String methodName, ArchitectureParameters architectureParameters, TrainingParameters trainingParameters, NormalizationParameters normalizationParameters) throws OptionsDialogException { resource = ResourceBundle .getBundle("neuralnetworktoolkit.gui.options.resources.OptionsDialogResource"); options = new String[2]; options[OK_BUTTON] = resource.getString("ok"); options[CANCEL_BUTTON] = resource.getString("cancel"); this.parameters = architectureParameters; this.trainingParameters = trainingParameters; this.normalizationParameters = normalizationParameters; try { architecturePanel = (ArchitecturePanel) Class.forName( "neuralnetworktoolkit.gui.options.architecture." + architecture + "Panel").newInstance(); trainingMethodPanel = (TrainingMethodPanel) Class.forName( "neuralnetworktoolkit.gui.options.method." + trainingMethod.substring(trainingMethod .lastIndexOf('.') + 1) + "Panel") .newInstance(); normalizationPanel = new NormalizationPanel(normalizationParameters); architecturePanel.setParameters(architectureParameters); architecturePanel.initializeComponents(true); trainingMethodPanel.setParameters(trainingParameters); trainingMethodPanel.initializeComponents(true); optionsTab = new JTabbedPane(); optionsTab.addTab(resource.getString("architecturePanel"), architecturePanel); optionsTab.addTab(resource.getString("trainingMethodPanel") + " - " + methodName, trainingMethodPanel); optionsTab.addTab(resource.getString("normalizationPanel"), normalizationPanel); dialogItems = new Object[1]; dialogItems[0] = optionsTab; } catch (InstantiationException e) { throw new OptionsDialogException(resource.getString("error") + e.getMessage(), e); } catch (IllegalAccessException e) { throw new OptionsDialogException(resource.getString("error") + e.getMessage(), e); } catch (ClassNotFoundException e) { throw new OptionsDialogException(resource.getString("error") + e.getMessage(), e); } } //OptionsDialog() /** * @throws OptionsDialogException * * */ public void showDialog(JInternalFrame frame) throws OptionsDialogException { int result = -1; result = JOptionPane.showOptionDialog(frame, dialogItems, resource .getString("nntk"), JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[OK_BUTTON]); switch (result) { case OK_BUTTON: { this.parameters = architecturePanel.getParameters(); this.trainingParameters = trainingMethodPanel.getParameters(); this.normalizationParameters = normalizationPanel.getParameters(); } break; case CANCEL_BUTTON: { } break; default: { } break; } } //showDialog() /** * @return Returns the parameters. */ public ArchitectureParameters getParameters() { return parameters; } //getParameters() /** * @return Returns the trainingParameters. */ public TrainingParameters getTrainingParameters() { return trainingParameters; } //getTrainingParameters() /** * @return Returns the normalizationParameters. */ public NormalizationParameters getNormalizationParameters() { return normalizationParameters; } //getNormalizationParameters() } //OptionsFrame
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -