Package Interface

Source Code of Interface.TotaalTable

package Interface;

import java.util.Vector;

import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;

import Logica.DecimalPlaces;
import Logica.rekeningItem;

public class TotaalTable extends AbstractTableModel {
 
  private String[] fColumnName = {"Product", "Prijs", "Hoeveelheid", "Totaal", "#betaald", "Al betaald", "Nog betalen"};
  private Vector<rekeningItem> fData;
 
  public TotaalTable(Vector<rekeningItem> data) {
    fData = data;
  }

  @Override
  public int getColumnCount() {
    return fColumnName.length;
  }
 
  @Override
  public String getColumnName(int col) {
         return fColumnName[col].toString();
  }

  @Override
  public int getRowCount() {
    return fData.size();
  }

  @Override
  public Object getValueAt(int rowIndex, int columnIndex) {
    rekeningItem temp = fData.get(rowIndex);
    switch (columnIndex) {
    case 0:
      return temp.getProduct().getName();
    case 1:
      return "€" + DecimalPlaces.set2decimals(temp.getProduct().getPrijs());
    case 2:
      return temp.getHoeveelheid();
    case 3:
      return "€" + DecimalPlaces.set2decimals(temp.getTotaal());
    case 4:
      return temp.getAfgerekend();
    case 5:
      return "€" + DecimalPlaces.set2decimals(temp.getAfgerekend() * temp.getProduct().getPrijs());
    case 6:
      return "€" + DecimalPlaces.set2decimals(temp.getSubTotaal());
    default:
      return null;
    }
  }
   
    public boolean isCellEditable(int row, int col) {
        //Note that the data/cell address is constant,
        //no matter where the cell appears onscreen.
        return false;
   
   
    @SuppressWarnings("unchecked")
  @Override
  public Class getColumnClass(int c){
        switch (c) {
    case 0:
      return String.class;
    case 1:
      return String.class;
    case 2:
      return Integer.class;
    case 3:
      return String.class;
    case 4:
      return Integer.class;
    case 5:
      return String.class;
    case 6:
      return String.class;
    default:
      return Object.class;
    }
    }

}
TOP

Related Classes of Interface.TotaalTable

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.