예제 #1
0
  /**
   * Gatilho para atualizar os detalhes do produto na tela
   *
   * @param evt
   */
  private void tableProdutosMouseReleased(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_tableProdutosMouseReleased
    try {
      int row = this.tableProdutos.getSelectedRow();
      long ID = (long) this.tableProdutos.getModel().getValueAt(row, 0);

      Produto p = (Produto) this.controller.getObjModel().findBy(ID).get(0);
      Integer estoque = p.getSaldoEstoque();
      DecimalFormat df = new DecimalFormat("#,###");
      this.jLabelDescricao.setText(String.format("%s %s", p.getNome(), p.getDescricao()));
      this.jLabelEstoque.setText(df.format(estoque));
      this.jLabelPreco.setText(p.getFormatPrice());
      this.jLabelCategoria.setText(p.getCategoria().toString());
      jLabelEstoque.setForeground(Color.BLUE);
      jLabelEstoque.setToolTipText("");
      if (p.estoqueCritico()) {
        jLabelEstoque.setToolTipText(
            String.format("Nível crítico, abaixo de %s", p.getNivelCritico()));
        jLabelEstoque.setForeground(Color.RED);
      }
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }
  } // GEN-LAST:event_tableProdutosMouseReleased