Package com.kolakcc.loljclient.model.swing

Source Code of com.kolakcc.loljclient.model.swing.RunesInventoryTableModel

package com.kolakcc.loljclient.model.swing;


import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import com.kolakcc.loljclient.model.InventoryRune;


public class RunesInventoryTableModel extends AbstractTableModel {
  ArrayList<InventoryRune> runes = new ArrayList<InventoryRune>();
  private String[] columnNames = { "#", "Name" };

  public RunesInventoryTableModel() {
  }
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public Class getColumnClass(int c) {
    return String.class;
  }

  public int getColumnCount() {
    return this.columnNames.length;
  }

  public String getColumnName(int col) {
    return this.columnNames[col];
  }

  public InventoryRune getItemAt(int row) {
    return this.runes.get(row);
  }

  public int getRowCount() {
    return this.runes.size();
  }

  public Object getValueAt(int row, int col) {
    InventoryRune selectedObject = this.runes.get(row);
    switch (columnNames[col]) {
      case "#": return selectedObject.getAmount();
      case "Name": return selectedObject.getRune().getName();
    }
    return "???";
  }
  public void clear() {
    this.runes.clear();
    this.fireTableDataChanged();
  }
  public void add(InventoryRune rune) {
    this.runes.add(rune);
    this.fireTableDataChanged();
  }
}
TOP

Related Classes of com.kolakcc.loljclient.model.swing.RunesInventoryTableModel

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.