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");
  }
 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);
 }
Example #4
0
  void goToSpecificColumn(int selectedIndex) {
    int row = table.getSelectedRow();

    table.changeSelection(row, selectedIndex, true, true);
  }
Example #5
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);
  }