Package dnb.model

Source Code of dnb.model.LabelTableModel

package dnb.model;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import dnb.data.Label;

public class LabelTableModel extends AbstractTableModel {

 
  private static final long serialVersionUID = 1L;
  private final List<Label> labels;
 
 
  public LabelTableModel(List<Label> labels) {   
    this.labels = labels;
  }

 
  @Override
  public int getColumnCount() {   
    return 2;
  }

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

  @Override
  public Object getValueAt(int rowIndex, int columnIndex) { 
    if (columnIndex == 0) {
      return labels.get(rowIndex).getName();
    } else {
      Label l = labels.get(rowIndex);
      final int c = l.size();
      String entry = "";
      for (int i = 0; i < c; i++) {
        entry+= l.get(i) + " ";
      }
      return entry;
    }   
  }
  @Override
  public String getColumnName(int column) {
    if (column == 0) {
      return "Label Name";
    } else {
      return "Label codes";
   
  }
 
 
}
TOP

Related Classes of dnb.model.LabelTableModel

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.