/**
   * Resets the rollover state of all rollover components in the current cell except the component
   * given as a parameter.
   *
   * @param excludeComponent the component to exclude from the reset
   */
  public void resetRolloverState(Component excludeComponent) {
    if (!chatButton.equals(excludeComponent)) chatButton.getModel().setRollover(false);

    if (!callButton.equals(excludeComponent)) callButton.getModel().setRollover(false);

    if (!callVideoButton.equals(excludeComponent)) callVideoButton.getModel().setRollover(false);

    if (!desktopSharingButton.equals(excludeComponent))
      desktopSharingButton.getModel().setRollover(false);

    if (!addContactButton.equals(excludeComponent)) addContactButton.getModel().setRollover(false);

    if (customActionButtons != null) {
      Iterator<JButton> buttonsIter = customActionButtons.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();

        if (!button.equals(excludeComponent)) button.getModel().setRollover(false);
      }
    }

    if (customActionButtonsUIGroup != null) {
      Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();

        if (!button.equals(excludeComponent)) button.getModel().setRollover(false);
      }
    }
  }
예제 #2
0
    @Override
    public void actionPerformed(ActionEvent e) {
      JButton f = (JButton) e.getSource();

      if (f.equals(jbtn_buscar)) {
        buscarPelicula();
      }
      if (f.equals(jbtn_agregar)) {
        agregarPelicula();
      }
    }
예제 #3
0
  @Override
  public void actionPerformed(ActionEvent e) {
    JButton buttonPressed = (JButton) e.getSource();

    if (buttonPressed.equals(savingsButton)) {
      System.out.println("Opening Savings Account");
      savings = true;
    }

    if (buttonPressed.equals(checkingButton)) {
      System.out.println("Opening Savings Account");
      checking = true;
    }
  }
예제 #4
0
 @Override
 public void mouseClicked(MouseEvent event) {
   Object obj = event.getSource();
   if (obj instanceof JButton) {
     JButton clickedButton = (JButton) obj;
     if (clickedButton.equals(one)) {
       this.clearPanel();
       Game next = new Game(this.frame, 1, this.bc);
       next.setBounds(0, 0, this.getWidth(), this.getHeight());
       this.frame.setContentPane(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(two)) {
       this.clearPanel();
       Game next = new Game(this.frame, 2, this.bc);
       next.setBounds(0, 0, this.getWidth(), this.getHeight());
       this.frame.setContentPane(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(three)) {
       this.clearPanel();
       Game next = new Game(this.frame, 3, this.bc);
       next.setBounds(0, 0, this.frame.getWidth(), this.frame.getHeight());
       this.frame.setContentPane(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(four)) {
       this.clearPanel();
       Game next = new Game(this.frame, 4, this.bc);
       next.setBounds(0, 0, this.frame.getWidth(), this.frame.getHeight());
       // this.frame.setContentPane(next);
       this.frame.add(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(back)) {
       this.clearPanel();
       HomePanel next = new HomePanel(this.frame, bc);
       next.setBounds(0, 0, this.getWidth(), this.getHeight());
       // this.frame.setContentPane(next);
       this.frame.add(next);
       this.revalidate();
       this.repaint();
     }
   }
 }
예제 #5
0
  @Override
  public void actionPerformed(ActionEvent a) {
    JButton button = (JButton) a.getSource();

    if (button.equals(buttonOk)) {
      String url = txUrl.getText();
      String lien = txLien.getText();
      if (url == null || url.length() == 0 || lien == null || lien.length() == 0) {
        Controleur.creerOptionPane("error", "Veuillez entrer toutes les informations");
        return;
      }
      // on recupere le texte de l'editeur
      String texte = panAjoutParagraphe.getJEditorPane().getText();
      String texteFinal = "";

      // on le traite ligne par ligne
      Scanner sc = new Scanner(texte);
      sc.useDelimiter("\n");
      while (sc.hasNext()) {
        String ligne = sc.next();
        // si la ligne contient la balise de fin de paragraphe, on ajoute le lien
        if (ligne.contains("</body>"))
          texteFinal += "<a href=\"" + url + "\">" + lien + "</a>&nbsp;\n";
        else texteFinal += ligne + "\n"; // on ajoute la ligne au texte
      }
      panAjoutParagraphe.getJEditorPane().setText(texteFinal);
    }

    this.dispose();
  }
예제 #6
0
 @Override
 public void actionPerformed(ActionEvent e) {
   JButton button = (JButton) e.getSource();
   if (button.equals(clearButton)) {
     clearProgress();
   } else {
     cancle();
   }
 }
예제 #7
0
  private int[] getPosicao(JButton botao) {
    for (int i = 0; i < tamanho; i++) {
      for (int j = 0; j < tamanho; j++) {
        if (botao.equals(this.grid[i][j])) {
          return new int[] {i, j};
        }
      }
    }

    return new int[] {0, 0};
  }
예제 #8
0
 public void actionPerformed(ActionEvent event) {
   Object source = event.getSource();
   File atlasFolder = Settings.getInstance().getAtlasOutputDirectory();
   if (openProgramFolderButton.equals(source)) {
     try {
       OSUtilities.openFolderBrowser(atlasFolder);
     } catch (Exception e) {
       log.error("", e);
     }
   } else if (dismissWindowButton.equals(source)) {
     downloadController = null;
     closeWindow();
   } else if (abortAtlasCreationButton.equals(source)) {
     aborted = true;
     stopUpdateTask();
     if (downloadController != null) downloadController.abortAtlasCreation();
     else closeWindow();
   } else if (pauseResumeDownloadButton.equals(source)) {
     if (downloadController != null) downloadController.pauseResumeAtlasCreation();
   }
 }
예제 #9
0
 @Override
 public void actionPerformed(ActionEvent e) {
   JButton source = (JButton) e.getSource();
   Comparator<Band> comparator =
       new Comparator<Band>() {
         @Override
         public int compare(Band o1, Band o2) {
           return o1.getName().compareTo(o2.getName());
         }
       };
   if (source.equals(newAuthorButton)) {
     String returned =
         JOptionPane.showInputDialog(null, "Input:", source.getName(), JOptionPane.PLAIN_MESSAGE);
     if (returned != null) {
       Band tmp = new Band(returned, this.type);
       if (Collections.binarySearch(this.bands, tmp, comparator) < 0) {
         this.addRow(tmp);
       }
     }
   } else if (source.equals(selectAuthorButton)) {
     if (bands.size() == 0) {
       return;
     }
     Object arr[] = bands.toArray();
     Object returned =
         JOptionPane.showInputDialog(
             source,
             "Select one from following box",
             source.getName(),
             JOptionPane.QUESTION_MESSAGE,
             null,
             arr,
             arr[0]);
     if (returned != null) {
       Band tmp = (Band) returned;
       this.addRow(tmp);
     }
   }
   MabisLogger.getLogger().log(Level.INFO, "Action called by clicking at {0}", source.getName());
 }
예제 #10
0
    public void actionPerformed(ActionEvent e) {

      JButton pushed = (JButton) e.getSource();
      if (pushed.equals(upcomingConcerts)) {
        try {
          upcomingConcerts x = new upcomingConcerts();
        } catch (SQLException e1) {
          e1.printStackTrace();
        }
        userHomeScreenFrame.setVisible(false);
      }

      if (pushed.equals(viewConcerts)) {
        allConcerts x = new allConcerts();
        userHomeScreenFrame.setVisible(false);
      }

      if (pushed.equals(accountInfo)) {
        try {
          accountInformation x = new accountInformation();
        } catch (SQLException e1) {
          e1.printStackTrace();
        }
        userHomeScreenFrame.setVisible(false);
      }

      if (pushed.equals(recentPurchases)) {
        try {
          recentPurchases x = new recentPurchases();
        } catch (SQLException e1) {
          e1.printStackTrace();
        }
        userHomeScreenFrame.setVisible(false);
      }

      if (pushed.equals(feedBack)) {
        submitFeedback x = new submitFeedback();
      }
      if (pushed.equals(contactUs)) {
        contactUsScreen x = new contactUsScreen();
        userHomeScreenFrame.setVisible(false);
      }

      if (pushed.equals(logout)) {
        userHomeScreenFrame.dispose();
        LoginPage x = new LoginPage();
      }
      if (pushed.equals(exit)) System.exit(0);
    }
  /**
   * Handles buttons action events.
   *
   * @param evt the <tt>ActionEvent</tt> that notified us
   */
  public void actionPerformed(ActionEvent evt) {
    JButton sourceButton = (JButton) evt.getSource();

    if (sourceButton.equals(openFileButton)) {
      this.openFile(downloadFile);
    } else if (sourceButton.equals(openFolderButton)) {
      try {
        File downloadDir = GuiActivator.getFileAccessService().getDefaultDownloadDirectory();

        GuiActivator.getDesktopService().open(downloadDir);
      } catch (IllegalArgumentException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST"));
      } catch (NullPointerException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST"));
      } catch (UnsupportedOperationException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FILE_OPEN_NOT_SUPPORTED"));
      } catch (SecurityException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_PERMISSION"));
      } catch (IOException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_APPLICATION"));
      } catch (Exception e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open file.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_FAILED"));
      }
    } else if (sourceButton.equals(cancelButton)) {
      if (fileTransfer != null) fileTransfer.cancel();
    }
  }
예제 #12
0
  public boolean showWindow() {
    DialogDescriptor dd =
        new DialogDescriptor(
            this,
            NbBundle.getMessage(FilterEditor.class, "LBL_FilterEditor"),
            true, // NOI18N
            new Object[] {btnOk, btnCancel},
            btnOk,
            DialogDescriptor.DEFAULT_ALIGN,
            HelpCtx.DEFAULT_HELP,
            null);

    Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);

    dlg.setVisible(true);
    if (btnOk.equals(dd.getValue())) {
      updateFilters();
      return true;
    }
    return false;
  }
예제 #13
0
 @Override
 public void mouseMoved(MouseEvent e) {
   JList list = (JList) e.getComponent();
   Point pt = e.getPoint();
   int index = list.locationToIndex(pt);
   if (!list.getCellBounds(index, index).contains(pt)) {
     if (prevIndex >= 0) {
       Rectangle r = list.getCellBounds(prevIndex, prevIndex);
       listRepaint(list, r);
     }
     index = -1;
     prevButton = null;
     return;
   }
   if (index >= 0) {
     JButton button = getButton(list, pt, index);
     ButtonsRenderer renderer = (ButtonsRenderer) list.getCellRenderer();
     if (Objects.nonNull(button)) {
       renderer.rolloverIndex = index;
       if (!button.equals(prevButton)) {
         Rectangle r = list.getCellBounds(prevIndex, index);
         listRepaint(list, r);
       }
     } else {
       renderer.rolloverIndex = -1;
       Rectangle r = null;
       if (prevIndex == index) {
         if (prevIndex >= 0 && Objects.nonNull(prevButton)) {
           r = list.getCellBounds(prevIndex, prevIndex);
         }
       } else {
         r = list.getCellBounds(index, index);
       }
       listRepaint(list, r);
       prevIndex = -1;
     }
     prevButton = button;
   }
   prevIndex = index;
 }
예제 #14
0
  /**
   * converts from actionEvent (from inventory button) to InputEvent2D and notifies
   *
   * @param arg0 the ActionEvent
   */
  @Override
  public void actionPerformed(ActionEvent event) {
    if (event.getSource().getClass().equals(JButton.class)) {
      JButton pressed = (JButton) (event.getSource());
      if (pressed.equals(inventoryButton)) {
        notifyInputListeners(new InputEvent2D(new Command(CommandWord.inventory, null)));
        if (inventoryWin != null
            && inventoryWin
                .isDisplayable()) { // closes window if its already open when you click the button
          inventoryWin.dispose();
        } else {
          inventoryWindow();
        }
      } else if (pressed.equals(characterButton)) {
        notifyInputListeners(new InputEvent2D(new Command(CommandWord.character, null)));
        if (characterWindow != null && characterWindow.isDisplayable()) {
          characterWindow.dispose();
        } else {
          characterWindow();
        }
      } else if (pressed.equals(undoButton)) {
        notifyInputListeners(new InputEvent2D(new Command(CommandWord.undo, null)));
      } else if (pressed.equals(redoButton)) {
        notifyInputListeners(new InputEvent2D(new Command(CommandWord.redo, null)));
      } else if (pressed.equals(helpButton)) {
        notifyInputListeners(new InputEvent2D(new Command(CommandWord.help, null)));
      } else if (pressed.equals(quitButton)) {
        notifyInputListeners(new InputEvent2D(new Command(CommandWord.quit, null)));
      } else if (pressed.equals(saveButton)) {
        notifyInputListeners(new InputEvent2D(new Command(CommandWord.save, null)));
      } else if (pressed.getClass().equals(JButton.class)) { // inventory or character button
        JButton src = (JButton) event.getSource();
        if (src.getText().startsWith("drop")) {
          notifyInputListeners(
              new InputEvent2D(new Command(CommandWord.drop, "" + src.getText().substring(5))));

        } else {
          notifyInputListeners(new InputEvent2D(new Command(CommandWord.use, "" + src.getText())));
        }
        // updates windows
        if (inventoryWin != null && inventoryWin.isVisible()) {
          inventoryWindow();
        }
        if (characterWindow != null && characterWindow.isVisible()) {
          characterWindow();
        }
      }
    }
    if (event.getSource().getClass().equals(JTextField.class)) {
      JTextField source = (JTextField) (event.getSource());

      displayMessage(source.getText());

      String word1 = null;
      String word2 = null;

      Scanner tokenizer = new Scanner(source.getText());
      if (tokenizer.hasNext()) {
        word1 = tokenizer.next(); // get first word
        if (tokenizer.hasNext()) {
          word2 = tokenizer.next(); // get second word
          // note: we just ignore the rest of the input line.
        }
      }
      tokenizer.close();

      Command toNotify = new Command(CommandWord.getCommandFromString(word1), word2);
      notifyInputListeners(new InputEvent2D(toNotify));

      source.setText("");
    }
  }
예제 #15
0
    @Override
    public void actionPerformed(ActionEvent e) {
      JButton viewConcertButton = (JButton) (e.getSource());
      JButton updateConcertButton = (JButton) (e.getSource());
      JButton clearButton = (JButton) (e.getSource());
      JButton updateUpcomingConcerts = (JButton) (e.getSource());

      if (e.getSource().equals(back)) {
        db.closeDB();
        updateConcertFrame.setVisible(false);
        AdminHomeScreen x = new AdminHomeScreen(LoginPage.usernameCopy);
      }

      if (viewConcertButton.equals(viewConcert)) {
        if (updateConcertTf.getText().equals("")) {
          JOptionPane.showMessageDialog(
              null, "Please enter concert code", "Error", JOptionPane.ERROR_MESSAGE);
        } else {

          int concertCode = 0;

          try {
            concertCode = Integer.parseInt(updateConcertTf.getText());
          } catch (NumberFormatException e5) {
            JOptionPane.showMessageDialog(
                null,
                "Only enter Numbers of concert code",
                " Concert code Error",
                JOptionPane.ERROR_MESSAGE);
          }
          rset = db.getConcertsToChange(concertCode);

          try {
            updateConcertTf.setEditable(false);
            updateNameTf.setEditable(true);
            updateTypeTf.setEditable(true);
            updateLocationTf.setEditable(true);
            updateDateTf.setEditable(true);
            updateTicketsPriceTf.setEditable(true);
            updateConcertAvailablilityTf.setEditable(true);

            Date dateOfConcert = rset.getDate(5);

            String dateTf = dateOfConcert.toString();

            double price = rset.getDouble(6);
            String priceTf = Double.toString(price);

            updateNameTf.setText(rset.getString(2).trim());
            updateTypeTf.setText(rset.getString(3).trim());
            updateLocationTf.setText(rset.getString(4).trim());
            updateDateTf.setText(dateTf);
            updateTicketsPriceTf.setText(priceTf);
            updateConcertAvailablilityTf.setText(rset.getString(7).trim());
            rset.close();

          } catch (SQLException a) {
          }
        }
      }
      if (updateConcertButton.equals(updateConcert)) {
        String code = updateConcertTf.getText();
        String updateName = updateNameTf.getText();
        String updateType = updateTypeTf.getText();
        String updateLocation = updateLocationTf.getText();
        String updateDate = updateDateTf.getText();
        String updateTicketPrice = updateTicketsPriceTf.getText();
        String concertAvailable = updateConcertAvailablilityTf.getText();
        String cac = concertAvailable.trim();

        if (code.equals("")
            || updateName.equals("")
            || updateType.equals("")
            || updateLocation.equals("")
            || updateDate.equals("")
            || updateTicketPrice.equals("")
            || concertAvailable.equals("")) {
          JOptionPane.showMessageDialog(
              null, "All field must be filled in", "Error", JOptionPane.ERROR_MESSAGE);
        } else {

          double ticketPrice = 0;
          int concertCode = 0;
          Date d1 = null;

          try {
            ticketPrice = Double.parseDouble(updateTicketPrice);

          } catch (NumberFormatException e1) {
            JOptionPane.showMessageDialog(
                null,
                "Please enter a valid amount for price",
                "Price Error",
                JOptionPane.WARNING_MESSAGE);
          }

          try {

            concertCode = Integer.parseInt(updateConcertTf.getText());

          } catch (NumberFormatException e1) {
            JOptionPane.showMessageDialog(
                null,
                "The concert code must be only numbers",
                "Concert Code error",
                JOptionPane.WARNING_MESSAGE);
          }

          try {

            d1 = Date.valueOf(updateDate);

          } catch (java.lang.IllegalArgumentException e1) {
            JOptionPane.showMessageDialog(
                null,
                "Date Must be a correct date and in format of YYYY-MM-DD",
                "Date error",
                JOptionPane.WARNING_MESSAGE);
          }

          if (ticketPrice == 0.00 || concertCode == 0 || d1 == null) {

          } else {
            updateConcertTf.setEditable(true);
            db.updateConcert(
                concertCode,
                updateName,
                updateType,
                updateLocation,
                d1,
                ticketPrice,
                concertAvailable);
          }
        }
      }
      if (clearButton.equals(clear)) {
        updateConcertTf.setEditable(true);
        updateNameTf.setEditable(false);
        updateTypeTf.setEditable(false);
        updateLocationTf.setEditable(false);
        updateDateTf.setEditable(false);
        updateTicketsPriceTf.setEditable(false);
        updateConcertAvailablilityTf.setEditable(false);

        updateConcertTf.setText("");
        updateNameTf.setText("");
        updateTypeTf.setText("");
        updateLocationTf.setText("");
        updateDateTf.setText("");
        updateTicketsPriceTf.setText("");
        updateConcertAvailablilityTf.setText("");
      }
    }
  /**
   * Saves all configuration settings when the "Save" button is pressed.
   *
   * @param e the <tt>ActionEvent</tt> that notified us of the button action
   */
  public void actionPerformed(ActionEvent e) {
    JButton button = (JButton) e.getSource();

    if (button.equals(saveButton)) {
      Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet();

      while (configurationSet.hasNext()) {
        ChatRoomConfigurationFormField formField = configurationSet.next();

        // If the field is of type fixed the user could not change it,
        // so we skip it.
        if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) continue;

        JComponent c = uiFieldsTable.get(formField.getName());

        if (c instanceof JTextComponent) {
          String newValue = ((JTextComponent) c).getText();

          if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) {
            // extract values
            StringTokenizer idTokens =
                new StringTokenizer(newValue, System.getProperty("line.separator"));
            while (idTokens.hasMoreTokens()) {
              formField.addValue(idTokens.nextToken());
            }
          } else formField.addValue(newValue);
        } else if (c instanceof AbstractButton) {
          boolean isSelected = ((AbstractButton) c).isSelected();

          formField.addValue(isSelected);
        } else if (c instanceof JComboBox) {
          Object selectedObject = ((JComboBox) c).getSelectedItem();

          formField.addValue(selectedObject);
        } else if (c instanceof JPanel) {
          Component[] components = c.getComponents();

          for (Component comp : components) {
            if (!(comp instanceof JCheckBox)) continue;

            JCheckBox checkBox = (JCheckBox) comp;

            formField.addValue(checkBox.getText());
          }
        }
      }

      new Thread() {
        @Override
        public void run() {
          try {
            configForm.submit();
          } catch (Exception e) {
            new ErrorDialog(
                    ChatRoomConfigurationWindow.this,
                    GuiActivator.getResources().getI18NString("service.gui.ERROR"),
                    GuiActivator.getResources()
                        .getI18NString("service.gui.CHAT_ROOM_CONFIGURATION_SUBMIT_FAILED"),
                    e)
                .showDialog();
          }
        }
      }.start();
    }

    this.dispose();
  }