📄 chooseseparatordialog.java
字号:
/* * $RCSfile: ChooseSeparatorDialog.java,v $ * $Revision: 1.5 $ * $Date: 2005/04/30 02:43:46 $ * * 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.newnetwork;import java.util.ResourceBundle;import javax.swing.*;/** * Dialog box used to user select or insert the appropriate file * field separator, when loading data from a simple 'txt' file. * * @version $Revision: 1.5 $ - $Date: 2005/04/30 02:43:46 $ * * @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 ChooseSeparatorDialog { private static final String TAB = " "; private static final String SPACE = " "; private static final String POINT = "."; private static final String COMMA = ","; private static final String SEMICOLON = ";"; private static final String TAB_MESSAGE = "tab"; private static final String SPACE_MESSAGE = "space"; private static final String POINT_MESSAGE = "point"; private static final String COMMA_MESSAGE = "comma"; private static final String SEMICOLON_MESSAGE = "semicolon"; private static final int OK_BUTTON = 0; private static final int CANCEL_BUTTON = 1; private JComboBox combo = new JComboBox(); private JDesktopPane desktop; private Object[] dialogItems = new Object[2]; private String[] options = new String[2]; private String fieldSeparator = null; private ResourceBundle resources; /** * Creates a new choose separator dialog. Only attributes are * initialized. To show the dialog use {@link #showDialog() showDialog()}. * * @param desktop Desktop to show dialog. */ public ChooseSeparatorDialog(JDesktopPane desktop) { this.desktop = desktop; this.resources = ResourceBundle .getBundle("neuralnetworktoolkit.gui.newnetwork.resources.ChooseSeparatorDialogResource"); dialogItems[0] = resources.getString("dialogMessage"); combo.setEditable(true); combo.addItem(resources.getString(TAB_MESSAGE)); combo.addItem(resources.getString(SPACE_MESSAGE)); combo.addItem(resources.getString(POINT_MESSAGE)); combo.addItem(resources.getString(COMMA_MESSAGE)); combo.addItem(resources.getString(SEMICOLON_MESSAGE)); dialogItems[1] = combo; options[OK_BUTTON] = resources.getString("ok"); options[CANCEL_BUTTON] = resources.getString("cancel"); } //ChooseSeparatorDialog() /** * Shows the choose separator dialog. * * @return Separator choosed. */ public void showDialog() { int result = JOptionPane.showOptionDialog(desktop, dialogItems, resources.getString("nntk"), JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[OK_BUTTON]); switch (result) { case OK_BUTTON: fieldSeparator = (String) combo.getSelectedItem(); if (fieldSeparator.equals(resources.getString(TAB_MESSAGE))) fieldSeparator = TAB; else if (fieldSeparator.equals(resources.getString(SPACE_MESSAGE))) fieldSeparator = SPACE; else if (fieldSeparator.equals(resources.getString(POINT_MESSAGE))) fieldSeparator = POINT; else if (fieldSeparator.equals(resources.getString(COMMA_MESSAGE))) fieldSeparator = COMMA; else if (fieldSeparator.equals(resources .getString(SEMICOLON_MESSAGE))) fieldSeparator = SEMICOLON; break; case CANCEL_BUTTON: fieldSeparator = null; break; default: fieldSeparator = null; break; } } //showDialog() /** * Returns the selected file field separator. * * @return Returns the field separator. */ public String getFieldSeparator() { return fieldSeparator; } //getFieldSeparator() } //ChooseSeparatorDialog
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -