Package Interface

Source Code of Interface.Biertable

package Interface;

import java.util.Vector;

import javax.swing.table.AbstractTableModel;

import Logica.DecimalPlaces;
import Logica.Kassa;
import Logica.Rekening;

public class Biertable extends AbstractTableModel {
 
  private Vector<Rekening> fData;
  private String[] columnNames = {"#", "Naam", "Tafel", "# consumpties", "Opbrengesten", "Nog betalen"};
 
 
  public Biertable(Kassa kassa) {
    fData = kassa.getAllRekeningen();
  }

  @Override
  public int getColumnCount() {
    return columnNames.length;
  }
 
  public String getColumnName(int colm){
    return columnNames[colm];
  }

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

  @Override
  public Object getValueAt(int row, int colm) {
    Rekening temp = fData.get(row);
    switch (colm) {
    case 0:
      return row+1;
    case 1:
      return temp.getName();
    case 2:
      return temp.getTafel();
    case 3:
      return temp.getSize();
    case 4:
      try {
        return "€" + DecimalPlaces.set2decimals(temp.getTotaal());
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    case 5:
      try {
        return "€" + DecimalPlaces.set2decimals(temp.getSubTotaal());
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    default:
      return 0;
    }
  }
 
  public boolean isCellEditable(int row, int col) {
    return false;
    }
 
  @SuppressWarnings("unchecked")
  @Override
  public Class getColumnClass(int c){
        switch (c) {
    case 0:
      return Integer.class;
    case 1:
      return String.class;
    case 2:
      return Integer.class;
    case 3:
      return Integer.class;
    case 4:
      return String.class;
    case 5:
      return String.class;
    default:
      return Object.class;
    }
    }

}
TOP

Related Classes of Interface.Biertable

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.