List of usage examples for weka.gui JListHelper moveDown
public static void moveDown(JList list)
From source file:meka.gui.experimenter.BasicSetup.java
License:Open Source License
/** * Initializes the widgets.//from w ww . j av a 2 s.c om */ @Override protected void initGUI() { JPanel panel; JPanel panelClassifiers; JPanel panelDatasets; super.initGUI(); panel = new JPanel(new GridLayout(1, 2)); m_PanelSetup.add(panel, BorderLayout.CENTER); // classifiers panelClassifiers = new JPanel(new BorderLayout()); panelClassifiers.setBorder(BorderFactory.createTitledBorder("Classifiers")); panel.add(panelClassifiers); m_ModelClassifiers = new DefaultListModel<>(); m_ListClassifiers = new ListWithButtons(); m_ListClassifiers.getList().setModel(m_ModelClassifiers); m_ListClassifiers.getList().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateButtons(); } }); panelClassifiers.add(m_ListClassifiers, BorderLayout.CENTER); m_ButtonAddClassifier = new JButton("Add..."); m_ButtonAddClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addClassifier(); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonAddClassifier); m_ButtonEditClassifier = new JButton("Edit..."); m_ButtonEditClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editClassifier(); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonEditClassifier); m_ListClassifiers.addToButtonsPanel(new JLabel()); m_ButtonRemoveClassifier = new JButton("Remove"); m_ButtonRemoveClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeClassifiers(m_ListClassifiers.getList().getSelectedIndices()); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonRemoveClassifier); m_ButtonRemoveAllClassifiers = new JButton("Remove all"); m_ButtonRemoveAllClassifiers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeClassifiers(null); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonRemoveAllClassifiers); m_ListClassifiers.addToButtonsPanel(new JLabel()); m_ButtonMoveUpClassifier = new JButton("Up"); m_ButtonMoveUpClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JListHelper.moveUp(m_ListClassifiers.getList()); setModified(true); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonMoveUpClassifier); m_ButtonMoveDownClassifier = new JButton("Down"); m_ButtonMoveDownClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JListHelper.moveDown(m_ListClassifiers.getList()); setModified(true); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonMoveDownClassifier); // datasets panelDatasets = new JPanel(new BorderLayout()); panelDatasets.setBorder(BorderFactory.createTitledBorder("Datasets")); panel.add(panelDatasets); m_ModelDatasets = new DefaultListModel<>(); m_ListDatasets = new ListWithButtons(); m_ListDatasets.getList().setModel(m_ModelDatasets); m_ListDatasets.getList().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateButtons(); } }); panelDatasets.add(m_ListDatasets, BorderLayout.CENTER); m_ButtonAddDataset = new JButton("Add..."); m_ButtonAddDataset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addDataset(); } }); m_ListDatasets.addToButtonsPanel(m_ButtonAddDataset); m_ListDatasets.addToButtonsPanel(new JLabel()); m_ButtonRemoveDataset = new JButton("Remove"); m_ButtonRemoveDataset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeDatasets(m_ListDatasets.getList().getSelectedIndices()); } }); m_ListDatasets.addToButtonsPanel(m_ButtonRemoveDataset); m_ButtonRemoveAllDatasets = new JButton("Remove all"); m_ButtonRemoveAllDatasets.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeDatasets(null); } }); m_ListDatasets.addToButtonsPanel(m_ButtonRemoveAllDatasets); m_ListDatasets.addToButtonsPanel(new JLabel()); m_ButtonMoveUpDataset = new JButton("Up"); m_ButtonMoveUpDataset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JListHelper.moveUp(m_ListDatasets.getList()); setModified(true); } }); m_ListDatasets.addToButtonsPanel(m_ButtonMoveUpDataset); m_ButtonMoveDownDataset = new JButton("Down"); m_ButtonMoveDownDataset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JListHelper.moveDown(m_ListDatasets.getList()); setModified(true); } }); m_ListDatasets.addToButtonsPanel(m_ButtonMoveDownDataset); // parameters m_ParameterPanel = new ParameterPanel(); m_PanelSetup.add(m_ParameterPanel, BorderLayout.SOUTH); m_SpinnerNumRuns = new JSpinner(); ((SpinnerNumberModel) m_SpinnerNumRuns.getModel()).setMinimum(1); m_SpinnerNumRuns.setValue(10); m_SpinnerNumRuns.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { setModified(true); } }); m_ParameterPanel.addParameter("Runs", m_SpinnerNumRuns); m_ComboBoxEvaluation = new JComboBox<>(new String[] { "Cross-validation", "Percentage split", }); m_ComboBoxEvaluation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int index = m_ComboBoxEvaluation.getSelectedIndex(); if (index == -1) return; m_SpinnerNumFolds.setEnabled(index == 0); m_TextPercentage.setEnabled(index == 1); setModified(true); } }); m_ParameterPanel.addParameter("Evaluation", m_ComboBoxEvaluation); m_SpinnerNumFolds = new JSpinner(); ((SpinnerNumberModel) m_SpinnerNumFolds.getModel()).setMinimum(2); m_SpinnerNumFolds.setValue(10); m_SpinnerNumFolds.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { setModified(true); } }); m_ParameterPanel.addParameter("Folds", m_SpinnerNumFolds); m_TextPercentage = new JTextField("10", 5); m_TextPercentage.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { setModified(true); } @Override public void removeUpdate(DocumentEvent e) { setModified(true); } @Override public void changedUpdate(DocumentEvent e) { setModified(true); } }); m_ParameterPanel.addParameter("Split percentage", m_TextPercentage); m_CheckBoxPreserveOrder = new JCheckBox(); m_CheckBoxPreserveOrder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setModified(true); } }); m_ParameterPanel.addParameter("Preserve order", m_CheckBoxPreserveOrder); m_GOEStatisticsHandler = new GenericObjectEditor(true); m_GOEStatisticsHandler.setClassType(EvaluationStatisticsHandler.class); m_GOEStatisticsHandler.setValue(new KeyValuePairs()); m_GOEStatisticsHandler.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { setModified(true); } }); m_ParameterPanel.addParameter("Statistics", setPreferredSize(m_GOEStatisticsHandler.getCustomPanel())); m_ButtonNotes = new JButton("..."); m_ButtonNotes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editNotes(); } }); m_ParameterPanel.addParameter("Notes", m_ButtonNotes); }
From source file:meka.gui.experimenter.ExpertSetup.java
License:Open Source License
/** * Initializes the widgets./*ww w . ja v a 2 s. c om*/ */ @Override protected void initGUI() { JPanel panel; super.initGUI(); panel = new JPanel(new BorderLayout()); m_PanelSetup.add(panel, BorderLayout.CENTER); m_ModelClassifiers = new DefaultListModel<>(); m_ListClassifiers = new ListWithButtons(); m_ListClassifiers.getList().setModel(m_ModelClassifiers); m_ListClassifiers.getList().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateButtons(); } }); panel.add(m_ListClassifiers, BorderLayout.CENTER); m_ButtonAddClassifier = new JButton("Add..."); m_ButtonAddClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addClassifier(); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonAddClassifier); m_ButtonEditClassifier = new JButton("Edit..."); m_ButtonEditClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editClassifier(); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonEditClassifier); m_ListClassifiers.addToButtonsPanel(new JLabel()); m_ButtonRemoveClassifier = new JButton("Remove"); m_ButtonRemoveClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeClassifiers(m_ListClassifiers.getList().getSelectedIndices()); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonRemoveClassifier); m_ButtonRemoveAllClassifiers = new JButton("Remove all"); m_ButtonRemoveAllClassifiers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeClassifiers(null); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonRemoveAllClassifiers); m_ListClassifiers.addToButtonsPanel(new JLabel()); m_ButtonMoveUpClassifier = new JButton("Up"); m_ButtonMoveUpClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JListHelper.moveUp(m_ListClassifiers.getList()); setModified(true); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonMoveUpClassifier); m_ButtonMoveDownClassifier = new JButton("Down"); m_ButtonMoveDownClassifier.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JListHelper.moveDown(m_ListClassifiers.getList()); setModified(true); } }); m_ListClassifiers.addToButtonsPanel(m_ButtonMoveDownClassifier); m_ParameterPanel = new ParameterPanel(); panel.add(m_ParameterPanel, BorderLayout.SOUTH); m_GOEDatasets = new GenericObjectEditor(true); m_GOEDatasets.setClassType(DatasetProvider.class); m_GOEDatasets.setValue(new LocalDatasetProvider()); m_GOEDatasets.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { setModified(true); } }); m_ParameterPanel.addParameter("Datasets", setPreferredSize(m_GOEDatasets.getCustomPanel())); m_GOEEvaluator = new GenericObjectEditor(true); m_GOEEvaluator.setClassType(Evaluator.class); m_GOEEvaluator.setValue(new RepeatedRuns()); m_GOEEvaluator.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { setModified(true); } }); m_ParameterPanel.addParameter("Evaluator", setPreferredSize(m_GOEEvaluator.getCustomPanel())); m_GOEStatisticsHandler = new GenericObjectEditor(true); m_GOEStatisticsHandler.setClassType(EvaluationStatisticsHandler.class); m_GOEStatisticsHandler.setValue(new KeyValuePairs()); m_GOEStatisticsHandler.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { setModified(true); } }); m_ParameterPanel.addParameter("Statistics", setPreferredSize(m_GOEStatisticsHandler.getCustomPanel())); m_ButtonNotes = new JButton("..."); m_ButtonNotes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editNotes(); } }); m_ParameterPanel.addParameter("Notes", m_ButtonNotes); }