Package java.awt.event

Examples of java.awt.event.ActionListener


      // buttons
      panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
      getContentPane().add(panel, BorderLayout.SOUTH);
     
      m_OkButton.setMnemonic('O');
      m_OkButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          updateCapabilities();
          if (m_CapabilitiesFilter == null)
            m_CapabilitiesFilter = new Capabilities(null);
          m_CapabilitiesFilter.assign(m_Capabilities);
          m_Self.setVisible(false);
          showPopup();
        }
      });
      panel.add(m_OkButton);
     
      m_CancelButton.setMnemonic('C');
      m_CancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          m_Self.setVisible(false);
          showPopup();
        }
      });
View Full Code Here


      add(panel, BorderLayout.SOUTH);

      if (ClassDiscovery.hasInterface(CapabilitiesHandler.class, m_ClassType)) {
  // filter
  m_FilterButton.setMnemonic('F');
  m_FilterButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      if (e.getSource() == m_FilterButton) {
        CapabilitiesFilterDialog dialog = new CapabilitiesFilterDialog();
        dialog.setCapabilities(m_CapabilitiesFilter);
        dialog.setPopup(m_Self);
        dialog.setVisible(true);
        m_Support.firePropertyChange("", null, null);
        repaint();
      }
    }
  });
  panel.add(m_FilterButton);
 
  // remove
  m_RemoveFilterButton.setMnemonic('R');
  m_RemoveFilterButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      if (e.getSource() == m_RemoveFilterButton) {
        m_CapabilitiesFilter = null;
        m_Support.firePropertyChange("", null, null);
        repaint();
      }
    }
  });
  panel.add(m_RemoveFilterButton);
      }

      // close
      m_CloseButton.setMnemonic('C');
      m_CloseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          if (e.getSource() == m_CloseButton) {
            m_Self.setVisible(false);
          }
        }
View Full Code Here

    });
     
      m_OpenBut = new JButton("Open...");
      m_OpenBut.setToolTipText("Load a configured object");
      m_OpenBut.setEnabled(true);
      m_OpenBut.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      Object object = openObject();
      if (object != null) {
        // setValue takes care of: Making sure obj is of right type,
        // and firing property change.
        setValue(object);
        // Need a second setValue to get property values filled in OK.
        // Not sure why.
        setValue(object);
      }
    }
  });
     
      m_SaveBut = new JButton("Save...");
      m_SaveBut.setToolTipText("Save the current configured object");
      m_SaveBut.setEnabled(true);
      m_SaveBut.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      saveObject(m_Object);
    }
  });
     
      m_okBut = new JButton("OK");
      m_okBut.setEnabled(true);
      m_okBut.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {

      m_Backup = copyObject(m_Object);
      if ((getTopLevelAncestor() != null)
    && (getTopLevelAncestor() instanceof Window)) {
        Window w = (Window) getTopLevelAncestor();
        w.dispose();
      }
    }
  });
     
      m_cancelBut = new JButton("Cancel");
      m_cancelBut.setEnabled(true);
      m_cancelBut.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {    
      if (m_Backup != null) {
 
        m_Object = copyObject(m_Backup);
       
View Full Code Here

        c.fill = GridBagConstraints.HORIZONTAL;
        c.insets = new Insets(5, 5, 5, 5);
        panel.add(processIdTextField, c);

        startButton = new JButton("Start");
        startButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                start();
            }
        });
        c = new GridBagConstraints();
View Full Code Here

            m_HelpText.append("SYNOPSIS\n").append(globalInfo).append("\n\n");
            m_HelpBut = new JButton("More");
      m_HelpBut.setToolTipText("More information about "
                                     + className);
     
      m_HelpBut.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent a) {
                openHelpFrame();
                m_HelpBut.setEnabled(false);
              }
            });

      if (m_Target instanceof CapabilitiesHandler) {
        m_CapabilitiesBut = new JButton("Capabilities");
        m_CapabilitiesBut.setToolTipText("The capabilities of "
      + className);
       
        m_CapabilitiesBut.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent a) {
      openCapabilitiesHelpDialog();
      m_CapabilitiesBut.setEnabled(false);
    }
        });
View Full Code Here

    m_EditBut.setToolTipText("Open the current dataset in a Viewer for editing");
    m_SaveBut.setToolTipText("Save the working relation to a file");
    m_ApplyFilterBut.setToolTipText("Apply the current filter to the data");

    m_FileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    m_OpenURLBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  setInstancesFromURLQ();
      }
    });
    m_OpenDBBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        SqlViewerDialog dialog = new SqlViewerDialog(null);
        dialog.setVisible(true);
        if (dialog.getReturnValue() == JOptionPane.OK_OPTION)
          setInstancesFromDBQ(dialog.getURL(), dialog.getUser(),
                              dialog.getPassword(), dialog.getQuery(),
                              dialog.getGenerateSparseData());
      }
    });
    m_OpenFileBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  setInstancesFromFileQ();
      }
    });
    m_GenerateBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  generateInstances();
      }
    });
    m_UndoBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  undo();
      }
    });
    m_EditBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        edit();
      }
    });
    m_SaveBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  saveWorkingInstancesToFileQ();
      }
    });
    m_ApplyFilterBut.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    applyFilter((Filter) m_FilterEditor.getValue());
  }
      });
    m_AttPanel.getSelectionModel()
      .addListSelectionListener(new ListSelectionListener() {
  public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {   
      ListSelectionModel lm = (ListSelectionModel) e.getSource();
      for (int i = e.getFirstIndex(); i <= e.getLastIndex(); i++) {
        if (lm.isSelectedIndex(i)) {
    m_AttSummaryPanel.setAttribute(i);
    m_AttVisualizePanel.setAttribute(i);
    break;
        }
      }
    }
  }
    });


    m_InstSummaryPanel.setBorder(BorderFactory
         .createTitledBorder("Current relation"));
    JPanel attStuffHolderPanel = new JPanel();
    attStuffHolderPanel.setBorder(BorderFactory
          .createTitledBorder("Attributes"));
    attStuffHolderPanel.setLayout(new BorderLayout());
    attStuffHolderPanel.add(m_AttPanel, BorderLayout.CENTER);
    m_RemoveButton.setEnabled(false);
    m_RemoveButton.setToolTipText("Remove selected attributes.");
    m_RemoveButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    try {
      Remove r = new Remove();
      int [] selected = m_AttPanel.getSelectedAttributes();
      if (selected.length == 0) {
        return;
      }
      if (selected.length == m_Instances.numAttributes()) {
        // Pop up an error optionpane
        JOptionPane.showMessageDialog(PreprocessPanel.this,
              "Can't remove all attributes from data!\n",
              "Remove Attributes",
              JOptionPane.ERROR_MESSAGE);
        m_Log.logMessage("Can't remove all attributes from data!");
        m_Log.statusMessage("Problem removing attributes");
        return;
      }
      r.setAttributeIndicesArray(selected);
      applyFilter(r);
      m_RemoveButton.setEnabled(false);
    } catch (Exception ex) {
      if (m_Log instanceof TaskLogger) {
        ((TaskLogger)m_Log).taskFinished();
      }
      // Pop up an error optionpane
      JOptionPane.showMessageDialog(PreprocessPanel.this,
            "Problem filtering instances:\n"
            + ex.getMessage(),
            "Remove Attributes",
            JOptionPane.ERROR_MESSAGE);
      m_Log.logMessage("Problem removing attributes: " + ex.getMessage());
      m_Log.statusMessage("Problem removing attributes");
    }
  }
      });

    JPanel p1 = new JPanel();
    p1.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
    p1.setLayout(new BorderLayout());
    p1.add(m_RemoveButton, BorderLayout.CENTER);
    attStuffHolderPanel.add(p1, BorderLayout.SOUTH);
    m_AttSummaryPanel.setBorder(BorderFactory
        .createTitledBorder("Selected attribute"));
    m_UndoBut.setEnabled(false);
    m_EditBut.setEnabled(false);
    m_SaveBut.setEnabled(false);
    m_ApplyFilterBut.setEnabled(false);
   
    // Set up the GUI layout
    JPanel buttons = new JPanel();
    buttons.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
    buttons.setLayout(new GridLayout(1, 6, 5, 5));
    buttons.add(m_OpenFileBut);
    buttons.add(m_OpenURLBut);
    buttons.add(m_OpenDBBut);
    buttons.add(m_GenerateBut);
    buttons.add(m_UndoBut);
    buttons.add(m_EditBut);
    buttons.add(m_SaveBut);

    JPanel attInfo = new JPanel();

    attInfo.setLayout(new BorderLayout());
    attInfo.add(attStuffHolderPanel, BorderLayout.CENTER);

    JPanel filter = new JPanel();
    filter.setBorder(BorderFactory
        .createTitledBorder("Filter"));
    filter.setLayout(new BorderLayout());
    filter.add(m_FilterPanel, BorderLayout.CENTER);
    filter.add(m_ApplyFilterBut, BorderLayout.EAST);

    JPanel attVis = new JPanel();
    attVis.setLayout( new GridLayout(2,1) );
    attVis.add(m_AttSummaryPanel);

    JComboBox colorBox = m_AttVisualizePanel.getColorBox();
    colorBox.setToolTipText("The chosen attribute will also be used as the " +
          "class attribute when a filter is applied.");
    colorBox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent ie) {
  if (ie.getStateChange() == ItemEvent.SELECTED) {
    updateCapabilitiesFilter(m_FilterEditor.getCapabilitiesFilter());
  }
      }
    });
    final JButton visAllBut = new JButton("Visualize All");
    visAllBut.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent ae) {
    if (m_Instances != null) {
      try {
        final weka.gui.beans.AttributeSummarizer as =
    new weka.gui.beans.AttributeSummarizer();
View Full Code Here

                  new Dimension(
                        300,
                        (int) generatorPanel.getPreferredSize().getHeight()));
              generateButton.setMnemonic('G');
              generateButton.setToolTipText("Generates the dataset according the settings.");
              generateButton.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent evt){
                    // generate
                    generatorPanel.execute();
                    boolean generated = (generatorPanel.getInstances() != null);
                    if (generated)
View Full Code Here

    textData.setFont(
        new Font("Monospaced", Font.PLAIN, textData.getFont().getSize()));

    saveButton.setMnemonic('S');
    saveButton.setToolTipText("Saves the output to a file");
    saveButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt){
        JFileChooser filechooser = new JFileChooser();
        int result = filechooser.showSaveDialog(dialog);
        if (result == JFileChooser.APPROVE_OPTION) {
          try {
            BufferedWriter writer = new BufferedWriter(
                                      new FileWriter(
                                        filechooser.getSelectedFile()));
            writer.write(textData.getText());
            writer.flush();
            writer.close();
            JOptionPane.showMessageDialog(
              dialog,
              "Output successfully saved to file '"
              + filechooser.getSelectedFile() + "'!",
              "Information",
              JOptionPane.INFORMATION_MESSAGE);
          }
          catch (Exception e) {
            e.printStackTrace();
          }
          dialog.dispose();
        }
      }
    });
    closeButton.setMnemonic('C');
    closeButton.setToolTipText("Closes the dialog");
    closeButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt){
        dialog.dispose();
      }
    });
    panel.add(saveButton);
View Full Code Here

    try {
      convEd.setClassType(weka.core.converters.Loader.class);
      convEd.setValue(new weka.core.converters.CSVLoader());
      ((GenericObjectEditor.GOEPanel)convEd.getCustomEditor())
  .addOkListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        tryConverter((Loader)convEd.getValue(), f);
      }
    });
    } catch (Exception ex) {
View Full Code Here

    bg.add(m_ClassesToClustersBut);
    m_TrainBut.addActionListener(m_RadioListener);
    m_PercentBut.addActionListener(m_RadioListener);
    m_TestSplitBut.addActionListener(m_RadioListener);
    m_ClassesToClustersBut.addActionListener(m_RadioListener);
    m_SetTestBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  setTestSet();
      }
    });

    m_StartBut.setEnabled(false);
    m_StopBut.setEnabled(false);
    m_ignoreBut.setEnabled(false);
    m_StartBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  startClusterer();
      }
    });
    m_StopBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  stopClusterer();
      }
    });

    m_ignoreBut.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    setIgnoreColumns();
  }
      });
  
    m_History.setHandleRightClicks(false);
    // see if we can popup a menu for the selected result
    m_History.getList().addMouseListener(new MouseAdapter() {
  public void mouseClicked(MouseEvent e) {
    if (((e.getModifiers() & InputEvent.BUTTON1_MASK)
         != InputEvent.BUTTON1_MASK) || e.isAltDown()) {
      int index = m_History.getList().locationToIndex(e.getPoint());
      if (index != -1) {
        String name = m_History.getNameAtIndex(index);
        visualizeClusterer(name, e.getX(), e.getY());
      } else {
        visualizeClusterer(null, e.getX(), e.getY());
      }
    }
  }
      });
   
    m_ClassCombo.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
  updateCapabilitiesFilter(m_ClustererEditor.getCapabilitiesFilter());
      }
    });
View Full Code Here

TOP

Related Classes of java.awt.event.ActionListener

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.