/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
示例#2
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     profiles.delete(name);
   }
 }
示例#3
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == bOk) {
     onOKAction();
   } else if (e.getSource() == bExit) {
     onExitAction();
   }
 }
 /** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user pressed the ok button
   if (e.getSource() == ok_button) {
     filter_include_list = include_panel.getServiceList();
     filter_exclude_list = exclude_panel.getServiceList();
     if (status_box.isSelected()) {
       filter_active = status_active.isSelected();
       filter_complete = status_complete.isSelected();
     } else {
       filter_active = false;
       filter_complete = false;
     }
     ok_pressed = true;
     dialog.dispose();
   }
   // Check if the user pressed the cancel button
   if (e.getSource() == cancel_button) {
     dialog.dispose();
   }
   // Check if the user changed the status filter option
   if (e.getSource() == status_box) {
     status_active.setEnabled(status_box.isSelected());
     status_complete.setEnabled(status_box.isSelected());
   }
 }
 public void actionPerformed(ActionEvent evt) {
   if (evt.getSource() == ok) dispose();
   else if (evt.getSource() == pluginMgr) {
     new org.gjt.sp.jedit.pluginmgr.PluginManager(
         JOptionPane.getFrameForComponent(ErrorListDialog.this));
   }
 }
示例#6
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == enableDefaultEncryption) {
     loadStates();
   } else if (e.getSource() == cmdExpandAdvancedSettings) {
     pnlAdvancedSettings.setVisible(!pnlAdvancedSettings.isVisible());
   }
 }
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == top) {
     tabbedpane.setTabPlacement(JTabbedPane.TOP);
   } else if (e.getSource() == left) {
     tabbedpane.setTabPlacement(JTabbedPane.LEFT);
   } else if (e.getSource() == bottom) {
     tabbedpane.setTabPlacement(JTabbedPane.BOTTOM);
   } else if (e.getSource() == right) {
     tabbedpane.setTabPlacement(JTabbedPane.RIGHT);
   }
 }
示例#8
0
 /**
  * Handle ui actions.
  *
  * @param event The action event
  */
 public void actionPerformed(ActionEvent event) {
   String action = event.getActionCommand();
   if (action.equals(GuiUtils.CMD_SAVE)) {
     doSave();
   } else if (action.equals(GuiUtils.CMD_SAVEAS)) {
     doSaveAs();
   } else if (action.equals(GuiUtils.CMD_RENAME)) {
     doRename();
   } else if (action.equals(GuiUtils.CMD_NEW)) {
     doNew();
   } else if (action.equals(GuiUtils.CMD_IMPORT)) {
     doImport();
   } else if (action.equals(GuiUtils.CMD_EXPORT)) {
     doExport();
   } else if (action.equals(GuiUtils.CMD_REMOVE)) {
     doRemove();
   } else if (action.equals(GuiUtils.CMD_CLOSE)) {
     doClose();
   } else if (action.equals(CMD_BLACKBG)) {
     setCanvasBackground(Color.BLACK);
   } else if (action.equals(CMD_WHITEBG)) {
     setCanvasBackground(Color.WHITE);
   } else {
     super.actionPerformed(event);
   }
 }
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("ok")) System.out.println("do ok");
    else if (cmd.equals("cancel")) this.setVisible(false);
    else if (cmd.equals("help")) displayHelp();
  }
示例#10
0
 /**
  * The ActionListener implementation
  *
  * @param event the event.
  */
 public void actionPerformed(ActionEvent event) {
   String searchText = textField.getText().trim();
   if (searchText.equals("") && !saveAs.isSelected() && (fileLength > 10000000)) {
     textPane.setText("Blank search text is not allowed for large IdTables.");
   } else {
     File outputFile = null;
     if (saveAs.isSelected()) {
       outputFile = chooser.getSelectedFile();
       if (outputFile != null) {
         String name = outputFile.getName();
         int k = name.lastIndexOf(".");
         if (k != -1) name = name.substring(0, k);
         name += ".txt";
         File parent = outputFile.getAbsoluteFile().getParentFile();
         outputFile = new File(parent, name);
         chooser.setSelectedFile(outputFile);
       }
       if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) System.exit(0);
       outputFile = chooser.getSelectedFile();
     }
     textPane.setText("");
     Searcher searcher = new Searcher(searchText, event.getSource().equals(searchPHI), outputFile);
     searcher.start();
   }
 }
示例#11
0
  // ボタンが押されたときのイベント処理
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("submit")) { // 送信
      sendMessage("msg " + msgTextField.getText());
      msgTextField.setText("");
    } else if (cmd.equals("rename")) { // 名前の変更
      sendMessage("setName " + nameTextField.getText());
    } else if (cmd.equals("addRoom")) { // 部屋を作成
      String roomName = nameTextField.getText();
      sendMessage("addRoom " + roomName);
      enteredRoom(roomName);
      sendMessage("getUsers " + roomName);
    } else if (cmd.equals("enterRoom")) { // 入室
      Object room = roomList.getSelectedValue();
      if (room != null) {
        String roomName = room.toString();
        sendMessage("enterRoom " + roomName);
        enteredRoom(roomName);
      }
    } else if (cmd.equals("exitRoom")) { // 退室
      sendMessage("exitRoom " + roomName);
      exitedRoom();
    }
  }
    public void actionPerformed(ActionEvent e) {
      JGrid grid = (JGrid) e.getSource();
      SelectionModel sm = grid.getSelectionModel();
      anchorRow = sm.getAnchorRow();
      leadRow = sm.getLeadRow();
      anchorColumn = sm.getAnchorColumn();
      leadColumn = sm.getLeadColumn();

      int oldAnchorRow = anchorRow;
      int oldAnchorColumn = anchorColumn;

      if (grid.isEditing() && !grid.getCurrentCellEditor().stopCellEditing()) {
        return;
      }

      if (!inSelection) {
        moveWithinGridRange(grid, dx, dy, extend);
        if (!extend) {
          grid.changeSelection(anchorRow, anchorColumn, false, extend);
        } else {
          grid.changeSelection(leadRow, leadColumn, false, extend);
        }
      } else {
        if (moveWithinSelectedRange(grid, dx, dy, false)) {
          grid.changeSelection(anchorRow, anchorColumn, true, true);
        } else {
          grid.changeSelection(anchorRow, anchorColumn, false, false);
        }
      }
    }
示例#13
0
文件: Memory.java 项目: mattec92/KTH
 // Action - vad som händer om man klickar på knappen
 public void actionPerformed(ActionEvent e) {
   // Om man trycker på Avslutaknappen
   if (e.getSource() == exit) {
     // Stänger ner scorelistan och avslutar spelet
     System.exit(0);
   }
 }
  public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == popper) {
      showMenu();
    }
  }
示例#15
0
 public void actionPerformed(ActionEvent evt) {
   JComboBox cb = (JComboBox) evt.getSource();
   String format = (String) cb.getSelectedItem();
   if (format.equals("all formats")) {
     format = null;
   }
   fileList.setListData(findFiles(AUDIO_DIR, format));
 }
示例#16
0
 /**
  * Handle the event
  *
  * @param ae The event
  */
 public void actionPerformed(ActionEvent ae) {
   String cmd = ae.getActionCommand();
   if (cmd.equals(CMD_CONNECT)) {
     doConnect();
   } else {
     super.actionPerformed(ae);
   }
 }
示例#17
0
 public void actionPerformed(ActionEvent ae) {
   JButton b = (JButton) ae.getSource();
   //      System.out.println("NumberEar: button="+b.getText());
   int i = new Integer(b.getText()).intValue() - 1;
   number[date].setForeground(Color.BLUE);
   date = i;
   number[i].setForeground(Color.CYAN);
 }
 public void actionPerformed(ActionEvent e) {
   removeAll();
   refresh(((JComboBox) e.getSource()).getSelectedIndex());
   Component w = getParent();
   while (!(w instanceof Window)) w = w.getParent();
   if (w != null) ((Window) w).pack(); // ugly hack...
   return;
 }
示例#19
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     Profile profile = profiles.getProfile(name);
     Component[] components = selectorPanel.getComponents();
     for (int i = 0; i < components.length; i++) {
       Component comp = components[i];
       if (comp instanceof CPCheckBox) {
         CPCheckBox scb = (CPCheckBox) comp;
         String id = scb.element.id;
         boolean enb = profile.has(id);
         scb.setState(enb);
       }
     }
   }
 }
示例#20
0
 public void actionPerformed(ActionEvent event) {
   if (event.getSource().equals(launchBrowser)) {
     Configuration config = Configuration.getInstance();
     String ip = Util.getIPAddress();
     String protocol = "http" + (config.ssl ? "s" : "");
     String url = protocol + "://" + ip + ":" + config.port;
     Util.openURL(url);
   } else if (event.getSource().equals(stop)) {
     Util.shutdown();
     running = Util.isRunning();
     setStatus();
   } else if (event.getSource().equals(start)) {
     clearLogsDir();
     run();
     launchBrowser.requestFocusInWindow();
   }
 }
示例#21
0
  public void actionPerformed(ActionEvent e) {
    Object sender = e.getSource();
    /*
       if (sender == addButton)
       {
          if (project != null)
          {
            if (dirChooser != null)
            {
              dirChooser.setDialogTitle( "add a file" ) ;
              dirChooser.setFileSelectionMode( JFileChooser.FILES_ONLY) ;
              if ( dirChooser.showOpenDialog( this ) == JFileChooser.APPROVE_OPTION )
              {
                addFile( dirChooser.getSelectedFile() ) ;
              }
            }
            else System.out.println( "no chooser" ) ;
          }
          else System.out.println( "no project" ) ;
       }
       else if (sender == removeButton)
       {
         int row = table.getSelectedRow() ;

         if (project != null)
         {
           TProjectData data = project.getProjectData() ;
           TProjectFileList list = data.getAvailableLangs() ;

           TLanguageFile file = list.getData(row) ;

           list.removeLanguageVersion(file) ;

           if (list.getSize() < 1)
           {
             removeButton.setEnabled(false);
           }

           model.fireTableDataChanged();
         }

       }
       else if (sender == rescanButton)
       {

       }
       else
    */
    if (sender == this.baseButton) {
      //      dirChooser.setProjectFileFilter( (String) typeCombo.getSelectedItem() );
      dirChooser.setDialogTitle("select a base file");
      dirChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      if (dirChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        setBaseFile(dirChooser.getSelectedFile());
        rescan();
      }
    }
  }
示例#22
0
 public void actionPerformed(ActionEvent ev) {
   JComponent src = (JComponent) ev.getSource();
   if (src == saveAsMI) {
     saveAs();
   } else {
     int index = timeRangeMenu.getPopupMenu().getComponentIndex(src);
     setViewRange(rangeValues[index]);
   }
 }
 public void doAction(ActionEvent e) {
   String cmd = e.getActionCommand();
   // the new button creates a new set of texfields
   if (cmd.equals("new")) {
     Container container = getParent();
     if (container != null) container.setVisible(false);
     displayNewTxf("", "");
     if (container != null) container.setVisible(true);
   }
 }
示例#24
0
  // event handling
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnok) {
      PreparedStatement pstm;
      ResultSet rs;
      String sql;
      // if no entries has been made and hit ok button throw an error
      // you can do this step using try clause as well
      if ((tf1.getText().equals("") && (tf2.getText().equals("")))) {
        lblmsg.setText("Enter your details ");
        lblmsg.setForeground(Color.magenta);
      } else {

        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          Connection connect = DriverManager.getConnection("jdbc:odbc:student_base");
          System.out.println("Connected to the database");
          pstm = connect.prepareStatement("insert into student_base values(?,?)");
          pstm.setString(1, tf1.getText());
          pstm.setString(2, tf2.getText());
          // execute method to execute the query
          pstm.executeUpdate();
          lblmsg.setText("Details have been added to database");

          // closing the prepared statement  and connection object
          pstm.close();
          connect.close();
        } catch (SQLException sqe) {
          System.out.println("SQl error");
        } catch (ClassNotFoundException cnf) {
          System.out.println("Class not found error");
        }
      }
    }
    // upon clickin button addnew , your textfield will be empty to enternext record
    if (e.getSource() == btnaddnew) {
      tf1.setText("");
      tf2.setText("");
    }

    if (e.getSource() == btnexit) {
      System.exit(1);
    }
  }
示例#25
0
 public void actionPerformed(ActionEvent e) {
   for (int k = 0; k <= 4; k++) {
     // 先將全部顏色按鈕還原為浮凸狀
     btnCr[k].setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
     if (e.getSource() == btnCr[k]) {
       pane.setBackground(cr[k]);
       // 被點按的顏色按鈕呈凹陷狀
       btnCr[k].setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
     }
   }
 }
  /**
   * Handle action events coming from the buttons.
   *
   * @param evt, the associated ActionEvent.
   */
  public void actionPerformed(ActionEvent evt) {
    Object source = evt.getSource();

    if (source instanceof JButton) {
      if (source == pbSave) {
        chosen = tcc.getColor();
        onCancel();
      } else {
        onCancel();
      }
    }
  }
示例#27
0
 /**
  * Handle action events
  *
  * @param event event to handle
  */
 public void actionPerformed(ActionEvent event) {
   String cmd = event.getActionCommand();
   if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_APPLY)) {
     accept();
   }
   if (cmd.equals(GuiUtils.CMD_OK) || cmd.equals(GuiUtils.CMD_CANCEL)) {
     close();
   }
   if (cmd.equals(GuiUtils.CMD_HELP)) {
     ucar.unidata.ui.Help.getDefaultHelp().gotoTarget(helpId);
   }
 }
示例#28
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     if (name.equals("New...")) {
       name = JOptionPane.showInputDialog(selectorPanel, "Enter a name for the new profile.");
     }
     if ((name == null) || name.trim().equals("")) return;
     Profile profile = new Profile(name);
     Component[] components = selectorPanel.getComponents();
     for (int i = 0; i < components.length; i++) {
       Component comp = components[i];
       if (comp instanceof CPCheckBox) {
         CPCheckBox scb = (CPCheckBox) comp;
         String id = scb.element.id;
         if (scb.isSelected()) profile.add(id);
       }
     }
     profiles.add(profile);
   }
 }
 /** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user pressed the remove button
   if (e.getSource() == remove_button) {
     int row = table.getSelectedRow();
     model.removeRow(row);
     table.clearSelection();
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the remove all button
   if (e.getSource() == remove_all_button) {
     model.clearAll();
     table.setRowSelectionInterval(0, 0);
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the filter button
   if (e.getSource() == filter_button) {
     filter.showDialog();
     if (filter.okPressed()) {
       // Update the display with new filter
       model.setFilter(filter);
       table.repaint();
     }
   }
   // Check if the user pressed the start button
   if (e.getSource() == start_button) {
     start();
   }
   // Check if the user pressed the stop button
   if (e.getSource() == stop_button) {
     stop();
   }
   // Check if the user wants to switch layout
   if (e.getSource() == layout_button) {
     details_panel.remove(details_soap);
     details_soap.removeAll();
     if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
       details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
     } else {
       details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     }
     details_soap.setTopComponent(request_panel);
     details_soap.setRightComponent(response_panel);
     details_soap.setResizeWeight(.5);
     details_panel.add(details_soap, BorderLayout.CENTER);
     details_panel.validate();
     details_panel.repaint();
   }
   // Check if the user is changing the reflow option
   if (e.getSource() == reflow_xml) {
     request_text.setReflowXML(reflow_xml.isSelected());
     response_text.setReflowXML(reflow_xml.isSelected());
   }
 }
  /**
   * An interface action has been performed. Find out what it was and handle it.
   *
   * @param event The event that has occured.
   */
  public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();

    if (command.equals("0")
        || command.equals("1")
        || command.equals("2")
        || command.equals("3")
        || command.equals("4")
        || command.equals("5")
        || command.equals("6")
        || command.equals("7")
        || command.equals("8")
        || command.equals("9")) {
      int number = Integer.parseInt(command);
      calc.numberPressed(number);
    } else if (command.equals("A")
        || command.equals("B")
        || command.equals("C")
        || command.equals("D")
        || command.equals("E")
        || command.equals("F")) {
      int number = getNumberFromHexString(command);
      calc.numberPressed(number);
    } else if (command.equals("+")) {
      calc.plus();
    } else if (command.equals("-")) {
      calc.minus();
    } else if (command.equals("=")) {
      calc.equals();
    } else if (command.equals("C")) {
      calc.clear();
    } else if (command.equals("?")) {
      showInfo();
    }
    // Exercise 1 multi
    else if (command.equals("*")) {
      calc.multiplication();
    }
    // Exercise 1 division
    else if (command.equals("/")) {
      calc.division();
    } else if (command.equals("Cl")) {
      // had to change this, so it works in hexadecimal mode
      calc.clear();
    } else if (command.equals("Hexadecimal mode")) {
      calc.flipHexSwitch(); // flip the switch
    }

    // else unknown command.

    redisplay();
  }