コード例 #1
0
ファイル: MemoryGameB.java プロジェクト: sandy880/MemoryGame
  public void run() {
    for (int j = 0; j < 20; j++) butI[j].removeActionListener(this);

    Wait.manySec(10);
    if (but.getIcon() == butn.getIcon()) {
      but.setVisible(false);
      butn.setVisible(false);
    } else {
      but.setIcon(iconOrg);
      butn.setIcon(iconOrg);
    }

    isVisibl();
    for (int j = 0; j < 20; j++) butI[j].addActionListener(this);
  }
コード例 #2
0
 public void actionPerformed(ActionEvent e) {
   if (cChooser == null) {
     cChooser = new JColorChooser();
   }
   Color color =
       cChooser.showDialog(
           target, "Available Colors", ((ColoredIcon) target.getIcon()).getCurrentColor());
   target.setIcon(new ColoredIcon(color));
   target.doClick();
 }
コード例 #3
0
ファイル: SearchManager2.java プロジェクト: steog88/jabref
  public SearchManager2(JabRefFrame frame, SidePaneManager manager) {
    super(manager, GUIGlobals.getIconUrl("search"), Globals.lang("Search"));

    this.frame = frame;
    incSearcher = new IncrementalSearcher(Globals.prefs);

    // setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.magenta));

    searchReq =
        new JCheckBoxMenuItem(
            Globals.lang("Search required fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_REQ));
    searchOpt =
        new JCheckBoxMenuItem(
            Globals.lang("Search optional fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_OPT));
    searchGen =
        new JCheckBoxMenuItem(
            Globals.lang("Search general fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_GEN));
    searchAll =
        new JCheckBoxMenuItem(
            Globals.lang("Search all fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL));
    regExpSearch =
        new JCheckBoxMenuItem(
            Globals.lang("Use regular expressions"),
            Globals.prefs.getBoolean(JabRefPreferences.REG_EXP_SEARCH));

    increment = new JRadioButton(Globals.lang("Incremental"), false);
    floatSearch = new JRadioButton(Globals.lang("Float"), true);
    hideSearch = new JRadioButton(Globals.lang("Filter"), true);
    showResultsInDialog = new JRadioButton(Globals.lang("Show results in dialog"), true);
    searchAllBases =
        new JRadioButton(
            Globals.lang("Global search"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL_BASES));
    ButtonGroup types = new ButtonGroup();
    types.add(increment);
    types.add(floatSearch);
    types.add(hideSearch);
    types.add(showResultsInDialog);
    types.add(searchAllBases);

    select = new JCheckBoxMenuItem(Globals.lang("Select matches"), false);
    increment.setToolTipText(Globals.lang("Incremental search"));
    floatSearch.setToolTipText(Globals.lang("Gray out non-matching entries"));
    hideSearch.setToolTipText(Globals.lang("Hide non-matching entries"));
    showResultsInDialog.setToolTipText(Globals.lang("Show search results in a window"));

    // Add an item listener that makes sure we only listen for key events
    // when incremental search is turned on.
    increment.addItemListener(this);
    floatSearch.addItemListener(this);
    hideSearch.addItemListener(this);
    showResultsInDialog.addItemListener(this);
    // Add the global focus listener, so a menu item can see if this field was focused when
    // an action was called.
    searchField.addFocusListener(Globals.focusListener);

    if (searchAll.isSelected()) {
      searchReq.setEnabled(false);
      searchOpt.setEnabled(false);
      searchGen.setEnabled(false);
    }
    searchAll.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent event) {
            boolean state = !searchAll.isSelected();
            searchReq.setEnabled(state);
            searchOpt.setEnabled(state);
            searchGen.setEnabled(state);
          }
        });

    caseSensitive =
        new JCheckBoxMenuItem(
            Globals.lang("Case sensitive"),
            Globals.prefs.getBoolean(JabRefPreferences.CASE_SENSITIVE_SEARCH));

    highLightWords =
        new JCheckBoxMenuItem(
            Globals.lang("Highlight Words"),
            Globals.prefs.getBoolean(JabRefPreferences.HIGH_LIGHT_WORDS));

    searchAutoComplete =
        new JCheckBoxMenuItem(
            Globals.lang("Autocomplete names"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_AUTO_COMPLETE));
    settings.add(select);

    // 2005.03.29, trying to remove field category searches, to simplify
    // search usability.
    // settings.addSeparator();
    // settings.add(searchReq);
    // settings.add(searchOpt);
    // settings.add(searchGen);
    // settings.addSeparator();
    // settings.add(searchAll);
    // ---------------------------------------------------------------
    settings.addSeparator();
    settings.add(caseSensitive);
    settings.add(regExpSearch);
    settings.addSeparator();
    settings.add(highLightWords);
    settings.addSeparator();
    settings.add(searchAutoComplete);

    searchField.addActionListener(this);
    searchField.addCaretListener(this);
    search.addActionListener(this);
    searchField.addFocusListener(
        new FocusAdapter() {

          @Override
          public void focusGained(FocusEvent e) {
            if (increment.isSelected()) {
              searchField.setText("");
            }
          }

          @Override
          public void focusLost(FocusEvent e) {
            incSearch = false;
            incSearchPos = -1; // Reset incremental
            // search. This makes the
            // incremental search reset
            // once the user moves focus to
            // somewhere else.
            if (increment.isSelected()) {
              // searchField.setText("");
              // System.out.println("focuslistener");
            }
          }
        });
    escape.addActionListener(this);
    escape.setEnabled(false); // enabled after searching

    openset.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (settings.isVisible()) {
              // System.out.println("oee");
              // settings.setVisible(false);
            } else {
              JButton src = (JButton) e.getSource();
              settings.show(src, 0, openset.getHeight());
            }
          }
        });

    searchAutoComplete.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            Globals.prefs.putBoolean(
                JabRefPreferences.SEARCH_AUTO_COMPLETE, searchAutoComplete.isSelected());
            if (SearchManager2.this.frame.basePanel() != null) {
              SearchManager2.this.frame.basePanel().updateSearchManager();
            }
          }
        });
    Insets margin = new Insets(0, 2, 0, 2);
    // search.setMargin(margin);
    escape.setMargin(margin);
    openset.setMargin(margin);
    JButton help = new JButton(GUIGlobals.getImage("help"));
    int butSize = help.getIcon().getIconHeight() + 5;
    Dimension butDim = new Dimension(butSize, butSize);
    help.setPreferredSize(butDim);
    help.setMinimumSize(butDim);
    help.setMargin(margin);
    help.addActionListener(new HelpAction(Globals.helpDiag, GUIGlobals.searchHelp, "Help"));

    // Select the last used mode of search:
    if (Globals.prefs.getBoolean(JabRefPreferences.INCREMENT_S)) {
      increment.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.FLOAT_SEARCH)) {
      floatSearch.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.SHOW_SEARCH_IN_DIALOG)) {
      showResultsInDialog.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL_BASES)) {
      searchAllBases.setSelected(true);
    } else {
      hideSearch.setSelected(true);
    }

    JPanel main = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    main.setLayout(gbl);
    GridBagConstraints con = new GridBagConstraints();
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.fill = GridBagConstraints.BOTH;
    con.weightx = 1;

    gbl.setConstraints(searchField, con);
    main.add(searchField);
    // con.gridwidth = 1;
    gbl.setConstraints(search, con);
    main.add(search);
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(escape, con);
    main.add(escape);
    con.insets = new Insets(0, 2, 0, 0);
    gbl.setConstraints(increment, con);
    main.add(increment);
    gbl.setConstraints(floatSearch, con);
    main.add(floatSearch);
    gbl.setConstraints(hideSearch, con);
    main.add(hideSearch);
    gbl.setConstraints(showResultsInDialog, con);
    main.add(showResultsInDialog);
    gbl.setConstraints(searchAllBases, con);
    main.add(searchAllBases);
    con.insets = new Insets(0, 0, 0, 0);
    JPanel pan = new JPanel();
    GridBagLayout gb = new GridBagLayout();
    gbl.setConstraints(pan, con);
    pan.setLayout(gb);
    con.weightx = 1;
    con.gridwidth = 1;
    gb.setConstraints(openset, con);
    pan.add(openset);
    con.weightx = 0;
    gb.setConstraints(help, con);
    pan.add(help);
    main.add(pan);
    main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));

    setContentContainer(main);

    searchField.getInputMap().put(Globals.prefs.getKey("Repeat incremental search"), "repeat");

    searchField
        .getActionMap()
        .put(
            "repeat",
            new AbstractAction() {

              @Override
              public void actionPerformed(ActionEvent e) {
                if (increment.isSelected()) {
                  repeatIncremental();
                }
              }
            });
    searchField.getInputMap().put(Globals.prefs.getKey("Clear search"), "escape");
    searchField
        .getActionMap()
        .put(
            "escape",
            new AbstractAction() {

              @Override
              public void actionPerformed(ActionEvent e) {
                hideAway();
                // SearchManager2.this.actionPerformed(new ActionEvent(escape, 0, ""));
              }
            });
    setSearchButtonSizes();
    updateSearchButtonText();
  }
コード例 #4
0
ファイル: ArcViewer.java プロジェクト: ArcESCOM/SpartanHud
  public void actionPerformed(ActionEvent event) {

    if (posicion == -2) posicion = indexaux;

    // Abrir nueva imagen
    if (event.getSource() == carpeta) {

      siguiente.setEnabled(true);
      atras.setEnabled(true);
      presentacion.setEnabled(true);
      grid.setEnabled(true);
      bcomentario.setEnabled(true);
      zoom.setEnabled(true);

      imagenesbean.clear();

      if (imagenes != null) {
        imagenes.clear();
      }

      returnChooser = chooser.showOpenDialog(ArcViewer.this);
      imagenes = lista.Miranda(chooser, returnChooser);

      for (int asd1 = 0; asd1 < imagenes.size(); asd1++) {
        imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0));
      }

      String getImgSelected = chooser.getSelectedFile().getPath();

      for (int index = 0; index < imagenesbean.size(); index++) {
        if (getImgSelected.equals(imagenesbean.get(index).getIcon())) {
          imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon()));
          indexaux = index;
        }
      }
    }

    // Imagen siguiente
    if (event.getSource() == siguiente) {
      posicion++;
      if (posicion >= imagenesbean.size()) {
        posicion = 0;
      }

      imagen.setIcon(
          ajustar.ajusteImg(
              new ImageIcon(imagenesbean.get(posicion).getIcon()),
              imagenesbean.get(posicion).getAncho(),
              imagenesbean.get(posicion).getAlto(),
              areaventana.getWidth() - 50,
              areaventana.getHeight()));
    }

    // Imagen anterior
    if (event.getSource() == atras) {
      posicion--;
      if (posicion == -1) {
        posicion = imagenesbean.size() - 1;
      }

      imagen.setIcon(
          ajustar.ajusteImg(
              new ImageIcon(imagenesbean.get(posicion).getIcon()),
              imagenesbean.get(posicion).getAncho(),
              imagenesbean.get(posicion).getAlto(),
              areaventana.getWidth() - 50,
              areaventana.getHeight()));
    }

    // Presentacion iniciar/detener
    if (event.getSource() == presentacion) {

      if (isPresentacion == false) {
        grid.setVisible(false);
        atras.setVisible(false);
        siguiente.setVisible(false);
        carpeta.setVisible(false);
        bcomentario.setVisible(false);
        zoom.setVisible(false);
        ptiempo.setVisible(true);
      }

      if (isPresentacion == true) {
        grid.setVisible(true);
        atras.setVisible(true);
        siguiente.setVisible(true);
        carpeta.setVisible(true);
        bcomentario.setVisible(true);
        zoom.setVisible(true);
        ptiempo.setVisible(false);
      }

      if (presentacion.getIcon() == imgPausa) {
        slide.detener();
        posicion = slide.getPosicion();
        presentacion.setIcon(imgPlay);
        isPresentacion = false;
        return;
      }

      if (presentacion.getIcon() == imgPlay) {
        slide.setTodo(posicion, imagen, imagenesbean, areaventana, ptiempo);
        new Thread(slide, "prueba").start();
        presentacion.setIcon(imgPausa);
        isPresentacion = true;
        return;
      }
    }

    // Modo rejilla
    if (event.getSource() == grid) {

      imagen.setVisible(false);
      siguiente.setVisible(false);
      atras.setVisible(false);
      presentacion.setVisible(false);
      grid.setVisible(false);
      bcomentario.setVisible(false);
      zoom.setVisible(false);
      carpeta.setVisible(false);
      ptiempo.setVisible(false);

      // desplazamiento.setVisible(true);

      if (corrobora == true) {
        for (int celular = 0; celular < imgButtonArray.length; celular++) {
          imgButtonArray[celular].setVisible(true);
        }
      }

      if (corrobora == false) {
        imgButtonArray = new JButton[imagenesbean.size()];

        for (int goku = 0; goku < imagenesbean.size(); goku++) {
          areaventana.add(imgButtonArray[goku] = new JButton());
          imgButtonArray[goku].setPreferredSize(new Dimension(200, 200));
          imgButtonArray[goku].addActionListener(this);
          imgButtonArray[goku].setBackground(colorGris);
          imgButtonArray[goku].setIcon(
              ajustar.ajusteCuadrado(new ImageIcon(imagenesbean.get(goku).getIcon())));
          corrobora = true;
        }
      }
    }

    // Comentario
    if (event.getSource() == bcomentario) {
      new Comentario(imagenesbean.get(posicion), posicion);
    }

    // Cuando se apreta un boton de la rejilla
    if (corrobora == true) {
      for (int alice = 0; alice < imgButtonArray.length; alice++) {
        if (event.getSource() == imgButtonArray[alice]) {
          for (int wonderland = 0; wonderland < imgButtonArray.length; wonderland++) {
            imgButtonArray[wonderland].setVisible(false);
          }
          posicion = alice;

          imagen.setIcon(
              ajustar.ajusteImg(
                  new ImageIcon(imagenesbean.get(posicion).getIcon()),
                  imagenesbean.get(posicion).getAncho(),
                  imagenesbean.get(posicion).getAlto(),
                  areaventana.getWidth() - 50,
                  areaventana.getHeight()));

          imagen.setVisible(true);
          siguiente.setVisible(true);
          atras.setVisible(true);
          presentacion.setVisible(true);
          grid.setVisible(true);
          bcomentario.setVisible(true);
          zoom.setVisible(true);
          carpeta.setVisible(true);
        }
      }
    }

    if (event.getSource() == zoom) {
      System.out.println("Haciendo un ZOOOOOOOOOOOOM");
    }
  }
コード例 #5
0
 ColorChooserAction(JButton target) {
   super(null, target.getIcon());
   this.target = target;
 }