public void buscarComputadora(JTable table) {
    JTextField marca = new JTextField();
    JTextField clave = new JTextField();
    Object[] mensaje = {
      "Marca:", marca,
      "Clave:", clave
    };

    int opcion =
        JOptionPane.showConfirmDialog(this, mensaje, "Buscar", JOptionPane.OK_CANCEL_OPTION);
    if (opcion == JOptionPane.OK_OPTION) {
      for (int i = 0; i < sistema.getEmpresa().getProductos().size(); i++) {
        try {
          if (marca
                  .getText()
                  .equalsIgnoreCase(sistema.getEmpresa().getProductos().get(i).getMarca())
              && Integer.parseInt(clave.getText())
                  == sistema.getEmpresa().getProductos().get(i).getClave()) {
            table.changeSelection(i, 0, false, false);
            JOptionPane.showMessageDialog(this, "Encontrado");
            return;
          }
        } catch (NumberFormatException ex) {
          JOptionPane.showMessageDialog(this, "Número inválido");
        }
      }
    }
    JOptionPane.showMessageDialog(this, "No se encontró el producto");
  }
Esempio n. 2
0
 @Override
 public void changeSelection(int row, int column, boolean toggle, boolean extend) {
   super.changeSelection(row, column, toggle, extend);
   TableCellEditor editor = getCellEditor(row, column);
   if (editor instanceof DefaultAutoFilterCellEditor) {
     if (editCellAt(row, column)) getEditorComponent().requestFocusInWindow();
   }
 }
 private void moveItemUp() {
   int index = menuItemsTable.getSelectedRow();
   // Return if nothing was selected.
   if (index == -1) return;
   // Return if the first item is selected.
   if (index == 0) return;
   nodeAttributesDialog.moveParameterItemUp(parameter, index);
   // TODO: Changing the selection doesn't have any effect on Mac.
   menuItemsTable.changeSelection(index - 1, 1, false, false);
 }
 private void moveItemDown() {
   int index = menuItemsTable.getSelectedRow();
   // Return if nothing was selected.
   if (index == -1) return;
   java.util.List<Parameter.MenuItem> items = parameter.getMenuItems();
   // Return if the last item is selected.
   if (index >= items.size() - 1) return;
   nodeAttributesDialog.moveParameterItemDown(parameter, index);
   // TODO: Changing the selection doesn't have any effect on Mac.
   menuItemsTable.changeSelection(index + 1, 1, false, false);
 }
    @Override
    public void onEvent(ChangeRankingThresholdEvent event) {
      int rankingThreshold = event.getRankingThreshold();

      // table model
      PeptideSpeciesPSMTableModel peptideSpeciesTableModel =
          (PeptideSpeciesPSMTableModel) table.getModel();
      peptideSpeciesTableModel.setRankingThreshold(rankingThreshold);
      table.changeSelection(
          0,
          peptideSpeciesTableModel.getColumnIndex(PeptideTableHeader.PEPTIDE_COLUMN.getHeader()),
          false,
          false);
    }
    @Override
    public void onEvent(PeptideSpeciesEvent event) {
      PeptideSpecies peptideSpecies = event.getPeptideSpecies();

      // table model
      PeptideSpeciesPSMTableModel peptideSpeciesTableModel =
          (PeptideSpeciesPSMTableModel) table.getModel();
      // delete all rows
      peptideSpeciesTableModel.removeAllRows();
      // get peptide
      if (peptideSpecies != null) {
        peptideSpeciesTableModel.addData(
            new Tuple<TableContentType, Object>(TableContentType.PEPTIDE_SPECIES, peptideSpecies));
        table.changeSelection(
            0,
            peptideSpeciesTableModel.getColumnIndex(PeptideTableHeader.PEPTIDE_COLUMN.getHeader()),
            false,
            false);
      }
    }
Esempio n. 7
0
  void goToSpecificColumn(int selectedIndex) {
    int row = table.getSelectedRow();

    table.changeSelection(row, selectedIndex, true, true);
  }
Esempio n. 8
0
  /**
   * Move the currently selected cell up or down by one cell.
   *
   * @param direction -1 for previous, +1 for next.
   */
  public void goToRow(int direction) {
    int row = table.getSelectedRow();
    int column = table.getSelectedColumn();

    table.changeSelection(row + direction, column, false, false);
  }