/** 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();
   }
 }
  public void actionPerformed(ActionEvent e) {

    // Handle open button action.
    if (e.getSource() == openButton) {
      int returnVal = fc.showOpenDialog(FileChooserDemo.this);

      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        // This is where a real application would open the file.
        log.append("Opening: " + file.getName() + "." + newline);
      } else {
        log.append("Open command cancelled by user." + newline);
      }
      log.setCaretPosition(log.getDocument().getLength());

      // Handle save button action.
    } else if (e.getSource() == saveButton) {
      int returnVal = fc.showSaveDialog(FileChooserDemo.this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        // This is where a real application would save the file.
        log.append("Saving: " + file.getName() + "." + newline);
      } else {
        log.append("Save command cancelled by user." + newline);
      }
      log.setCaretPosition(log.getDocument().getLength());
    }
  }
示例#3
0
  public void actionPerformed(ActionEvent ae) {

    try {
      if (ae.getSource() == b7) {

        rs = st.executeQuery("select count(*) from employeemaster");
        if (rs.next()) {
          t6.setText(rs.getString(1));
        }

        rs = st.executeQuery("select * from Head");
        if (rs.next()) {
          t1.setText(rs.getString(1));
          t2.setText(rs.getString(2));
          t7.setText(rs.getString(3));
          t4.setText(rs.getString(4));
          t5.setText(rs.getString(5));
          t3.setText(rs.getString(6));
        }
      } else if (ae.getSource() == b6) {
        dispose();
      }

    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, "Error is" + e);
    }
  }
 /**
  * * Each non abstract class that implements the ActionListener must have this method.
  *
  * @param e the action event.
  */
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == dumpButton) {
     String password = askForAdminPassword();
     if (password == null) {
       return;
     }
     String[] yw = queryMostRecentOrderYearAndWeek();
     String year = yw[0];
     String week = String.format("%02d", Integer.parseInt(yw[1]));
     initializeSaveChooser("DB_Dump_" + year + "_KW" + week + ".sql");
     String filename = askForDumpFilename();
     if (filename != null) {
       dumpDatabase(password, filename);
     }
     return;
   }
   if (e.getSource() == readButton) {
     String password = askForAdminPassword();
     if (password == null) {
       return;
     }
     initializeLoadChooser();
     String filename = askForReadFilename();
     if (filename != null) {
       readDatabase(password, filename);
       // update all tabs
       tabbedPane.recreateTabbedPane();
     }
   }
 }
示例#5
0
 /** Handle menu events. */
 public void actionPerformed(ActionEvent e) {
   if ((e.getSource() instanceof MenuItem)) {
     MenuItem item = (MenuItem) e.getSource();
     String cmd = e.getActionCommand();
     commandName = cmd;
     ImagePlus imp = null;
     if (item.getParent() == Menus.getOpenRecentMenu()) {
       new RecentOpener(cmd); // open image in separate thread
       return;
     } else if (item.getParent() == Menus.getPopupMenu()) {
       Object parent = Menus.getPopupMenu().getParent();
       if (parent instanceof ImageCanvas) imp = ((ImageCanvas) parent).getImage();
     }
     int flags = e.getModifiers();
     hotkey = false;
     actionPerformedTime = System.currentTimeMillis();
     long ellapsedTime = actionPerformedTime - keyPressedTime;
     if (cmd != null && (ellapsedTime >= 200L || !cmd.equals(lastKeyCommand))) {
       if ((flags & Event.ALT_MASK) != 0) IJ.setKeyDown(KeyEvent.VK_ALT);
       if ((flags & Event.SHIFT_MASK) != 0) IJ.setKeyDown(KeyEvent.VK_SHIFT);
       new Executer(cmd, imp);
     }
     lastKeyCommand = null;
     if (IJ.debugMode) IJ.log("actionPerformed: time=" + ellapsedTime + ", " + e);
   }
 }
示例#6
0
 public void actionPerformed(ActionEvent event) {
   PanImage1 panImage1 = new PanImage1();
   PanImage2 panImage2 = new PanImage2();
   PanImage3 panImage3 = new PanImage3();
   revalidate();
   if (event.getSource() == btnClick) {
     if (nImg == 0) {
       nImg = 3;
     } else {
       nImg--;
     }
   } else if (event.getSource() == btnClick2) {
     if (nImg == 4) {
       nImg = 1;
     } else {
       nImg++;
     }
   } else if (event.getSource() == btnClick3) {
     System.exit(0);
   }
   if (nImg == 1) {
     add(panImage1);
   }
   if (nImg == 2) {
     add(panImage2);
   }
   if (nImg == 3) {
     add(panImage3);
   }
 }
示例#7
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     profiles.delete(name);
   }
 }
示例#8
0
 public void actionPerformed(ActionEvent event) {
   if (event.getSource() == joinButton) {
     if (joinButton.isSelected()) {
       mThread =
           new MulticastThread(
               Integer.valueOf(portField.getText()), chatIPField.getText(), chatroomArea, true);
       (new Thread(mThread)).start();
     }
   }
   if (event.getSource() == sendButton) {
     mThread.send(usernameField.getText(), chatMsgField.getText());
     chatMsgField.setText("");
   }
   if (event.getSource() == leaveButton) {
     try {
       joinButton.setSelected(false);
       mThread.leave();
       System.out.println("Disconnected from chat ");
     } catch (Exception e) {
     }
   }
   if (event.getSource() == exitButton) {
     System.exit(0);
   }
 }
示例#9
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == salir) {
      JOptionPane.showMessageDialog(null, "Pantalla de Marlon");
    }

    if (e.getSource() == opc1) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }

    if (e.getSource() == opc2) {
      score = s + 10;
      JOptionPane.showMessageDialog(null, "Respuesta Correcta :0 ");
      Pregunta14 avance = new Pregunta14(score);
      dispose();
    }

    if (e.getSource() == opc3) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }

    if (e.getSource() == opc4) {
      JOptionPane.showMessageDialog(null, "Respuesta Incorrecta");
      Pregunta14 avance = new Pregunta14(s);
      dispose();
    }
  }
示例#10
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (td.getTabCount() > 0) {
     TextDocument ta = (TextDocument) td.getComponentAt(td.getSelectedIndex());
     Pattern pn = Pattern.compile(tf1.getText());
     Matcher mt = pn.matcher(ta.getText());
     if (e.getSource() == jb2) { // 取代
       ta.setText(mt.replaceAll(tf2.getText()));
     } else if (e.getSource() == jb1) { // 尋找
       Highlighter hl = ta.getHighlighter();
       hl.removeAllHighlights();
       while (mt.find()) {
         try {
           hl.addHighlight(
               mt.start(), mt.end(), new DefaultHighlighter.DefaultHighlightPainter(null));
         } catch (Exception ex) {
         }
       } // 開啟及關閉介面
     } else if (e.getSource() == replace_searchMenuItem) {
       System.out.println("Replace/Search is show:" + !show);
       if (show) {
         getContentPane().remove(jp);
         show = false;
       } else {
         getContentPane().add(jp, BorderLayout.SOUTH);
         show = true;
       }
       validate(); // 刷新容器
     }
   } else if (e.getSource() == replace_searchMenuItem) {
     JOptionPane.showMessageDialog(
         null, "尚無檔案,無法使用!", "Repace/Search error", JOptionPane.ERROR_MESSAGE);
   }
 }
 /** 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());
   }
 }
示例#12
0
    public void actionPerformed(ActionEvent event) {

      JMenuItem mi;
      String label = "";

      if (warningPopup == null) {
        warningPopup = new WarningDialog(textViewerFrame);
      }
      if ((editor1 == null) || (editor1.getDocument() == null)) {
        String errstr = "TextViewer:editor1 or document is null";
        warningPopup.display(errstr);
        return;
      }
      String actionStr = event.getActionCommand(); // is not makeing anysense
      // when keystrokes typed
      if ((event.getSource() instanceof JMenuItem)) {
        mi = (JMenuItem) event.getSource();
        label = mi.getText();
      } else if ((event.getSource() instanceof JTextArea)) { // keystroke
        label = "FindAgain"; // just set it to findagain
      } else {
        System.err.println("Debug:TextViewer:" + actionStr);
        System.err.println("Debug:TextViewer:" + event.getSource().toString());
        String errstr =
            "TextViewer:FindAction: "
                + event.getSource().toString()
                + " not an instance of JMenuItem or JTextArea";
        warningPopup.display(errstr);
        return;
      }

      if (label.equals("FindAgain")) {
        isFindAgain = true;
        lastFindStr = lastFindStr;
      } else {
        isFindAgain = false;
        lastFindStr = "";
      }
      StringBoolean content = new StringBoolean(lastFindStr, forwardFindDirection);

      boolean okPressed = mySearchDialog.display(content);
      if (!okPressed) {
        return;
      }
      lastFindStr = content.mystring;
      forwardFindDirection = content.myboolean;

      if (forwardFindDirection) {
        lastFindIndex = searchForward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);

      } else {
        lastFindIndex = searchBackward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);
      }
    }
 public void actionPerformed(ActionEvent E) {
   if (E.getSource() == yes) {
     dispose();
     server.shutdown();
     return;
   } else if (E.getSource() == cancel) {
     dispose();
     return;
   }
 }
示例#14
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == easy) {
      invSpeed = 50000;
      bombN = 1;
      timeDifficulty1 = 1000;
      distanceLimit = 400;
      monsterMultiplier = 1;
      multiplier = 1;
      setup();
    } else if (e.getSource() == hard) {
      invSpeed = 30000;
      bombN = 4;
      timeDifficulty1 = 500;
      distanceLimit = 200;
      monsterMultiplier = 2;
      multiplier = 2;
      setup();
    } else if (e.getSource() == back) {
      r = null;
      menu.setVisible(true);
      back.setVisible(false);
      this.revalidate();
      repaint();
    } else if (e.getSource() == howTo) {
      menu.removeAll();

      menu.add(howToBack);
      menu.add(howToIMGL);

      menu.revalidate();
      menu.repaint();
    } else if (e.getSource() == howToBack) {
      menu.remove(howToIMGL);
      menu.remove(howToBack);

      menu.add(keyboardSpeedL1);
      menu.add(keyboardSpeedL2);
      menu.add(easy);
      menu.add(hard);
      menu.add(howTo);
      menu.add(onePlayerRB);
      menu.add(twoPlayerRB);
      menu.add(mouseRB);
      menu.add(keyboardRB);
      menu.add(keyboardSpeedS1);
      menu.add(keyboardSpeedS2);
      menu.add(musicCB);
      menu.add(highscoreL);
      menu.add(menuIMGL);

      menu.revalidate();
      menu.repaint();
    }
  }
 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);
   }
 }
示例#16
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (td.getTabCount() > 0) {
     TextDocument ta = (TextDocument) td.getComponentAt(td.getSelectedIndex());
     if (e.getSource() == cutMenuItem) {
       ta.cut();
     } else if (e.getSource() == pasteMenuItem) {
       ta.paste();
     } else if (e.getSource() == copyMenutem) {
       ta.copy();
     }
   }
 }
示例#17
0
  /**
   * Calls the appropriate methods when the specified actions are performed.
   *
   * @param event The event that is to be reacted to.
   */
  public void actionPerformed(ActionEvent event) {
    // React to the load_button
    if (event.getSource().equals(load_button)) loadStrings();

    // React to the save_button
    else if (event.getSource().equals(save_button)) saveText();

    // React to the clear_button
    else if (event.getSource().equals(clear_button)) clearText();

    // React to the organize_button
    else if (event.getSource().equals(organize_button)) organizeText();
  }
 public void actionPerformed(ActionEvent e) {
   Object jbX = e.getSource();
   if (jbX == jbReg) {
     String an = tfAutoNr.getText();
     if (rg.registruotiAuto(an)) rodytiAutoRinkinius();
     else
       JOptionPane.showMessageDialog(
           this,
           "Registracija neįvyko:\n" + "arba kartojasi auto numeris arba nėra neregistruotų");
   }
   if (jbX == jbRasti) {
     String pag = tfAutoNr.getText();
     Automobilis a = rg.regAuto.get(pag);
     pag += a == null ? " automobilis nerastas" : "=" + a;
     JOptionPane.showMessageDialog(this, pag);
   }
   if (jbX == jbSkaityti) {
     rg.neregAuto.clear();
     String ats = rg.skaitytiNeregAutos("ban.automoto");
     JOptionPane.showMessageDialog(this, ats);
     rodytiAutoRinkinius();
   }
   if (jbX == jbSaveObj) {
     saveObject(rg, "temp.obj");
   }
   if (jbX == jbLoadObj) {
     loadObject("temp.obj");
     rodytiAutoRinkinius();
   }
 }
示例#19
0
 @Override
 public void actionPerformed(ActionEvent evt) {
   Object source = evt.getSource();
   if (source == run) run();
   else if (source == compile) compile();
   else if (source == compileG) compileGoal(false);
 }
示例#20
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();
   }
 }
示例#21
0
  public void actionPerformed(ActionEvent event) {
    JMenuItem source = (JMenuItem) (event.getSource());

    for (GraphView v : gp.getGraphViewList()) {
      if (v.getMenuText().equals(source.getText())) {
        v.view();
        repaint();
        return;
      }
    }

    for (GraphDrawer d : gp.getGraphDrawerList()) {
      if (d.getMenuText().equals(source.getText())) {
        d.layout();
        repaint();
        return;
      }
    }

    for (GraphUtility u : gp.getGraphUtilityList()) {
      if (u.getMenuText().equals(source.getText())) {
        u.apply();
        repaint();
        return;
      }
    }

    for (GraphExperiment ge : gp.getGraphExperimentList()) {
      if (ge.getMenuText().equals(source.getText())) {
        ge.experiment();
        repaint();
        return;
      }
    }
  }
  public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == popper) {
      showMenu();
    }
  }
示例#23
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == from) {
      String tmpFrom = from.getText().trim();
      String tmpTo = to.getText().trim();
      if (tmpFrom.equals("MST") || tmpFrom.equals("mst")) findMinSpan();
      else {
        try { // check if from exists
          // String str = from.getText();
          // fixa så man kan skippa att skriva första med stor bokstav
          tmpFrom = Character.toUpperCase(tmpFrom.charAt(0)) + tmpFrom.substring(1);
          int pos = noderna.findLeading(tmpFrom).getNodeNo();
          route.setText(introText + "\n");
          from.setText(noderna.find(pos).toString());
        } catch (NullPointerException npe) {
          route.setText(felTextStart + "\n");
          return;
        }
        if (!tmpTo.equals("")) {
          findShort();
        }
      }
    } else if (e.getSource() == to) {
      String tmpFrom = from.getText().trim();
      String tmpTo = to.getText().trim();
      if (tmpTo.equals("MST") || tmpTo.equals("mst")) findMinSpan();
      else {
        try { // check if to exists
          // String str = to.getText();
          tmpTo = Character.toUpperCase(tmpTo.charAt(0)) + tmpTo.substring(1);
          int pos = noderna.findLeading(tmpTo).getNodeNo();
          route.setText(introText + "\n");
          to.setText(noderna.find(pos).toString());
        } catch (NullPointerException npe) {
          route.setText(felTextStart + "\n");
          return;
        }
        if (!tmpFrom.equals("")) {
          findShort();
        }
      }

      /*
      else if ( ! from.getText().equals("") )
      	findShort();
      */
    }
  }
示例#24
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));
 }
示例#25
0
 public void actionPerformed(ActionEvent evt) {
   Object source = evt.getSource();
   if (source.equals(root)) {
     root.setSelectedIndex(directoryPane.changeRoot(root.getSelectedIndex()));
   } else if (source.equals(refresh)) {
     directoryPane.reloadTree();
   }
 }
 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;
 }
示例#27
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);
       }
     }
   }
 }
示例#28
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();
      }
    }
  }
示例#29
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnQAuswahl) {
      addQListBoxEintrag(dateiAuswählen());
    }
    if (e.getSource() == btnQEntfernen) {
      subQListBoxEintrag();
    }
    if (e.getSource() == btnZAuswahl) {
      addZListBoxEintrag(dateiAuswählen());
    }
    if (e.getSource() == btnZEntfernen) {
      subZListBoxEintrag();
    }
    if (e.getSource() == btnSync) {

      startCopy(
          (Path) quellJList.getSelectedValue().getValueMember(),
          (Path) zielJList.getSelectedValue().getValueMember());
    }
    if (e.getSource() == btnAbbruch) {
      setAbbruch();
    }
    if (e.getSource() == btnBackup) {
      MainNtray.bwvisible();
      this.invisible();
    }
  }
示例#30
0
    @Override
    public void actionPerformed(ActionEvent e) {

      Object source = e.getSource();

      if (source.equals(buttonSelect)) {
        selectFolder();
      }
    }