There are 1 code examples for javax.swing.table.DefaultTableCellRenderer.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: weka Package: weka.gui

Source Code: AttributeSummaryPanel.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Creates a tablemodel for the attribute being displayed
 * @param as		the attribute statistics
 * @param index	the index of the attribute
 */
protected void setTable(AttributeStats as,int index){
  if (as.nominalCounts != null) {
    Attribute att=m_Instances.attribute(index);
    Object[] colNames={"No.","Label","Count","Weight"};
    Object[][] data=new Object[as.nominalCounts.length][4];
    for (int i=0; i < as.nominalCounts.length; i++) {
      data[i][0]=new Integer(i + 1);
      data[i][1]=att.value(i);
      data[i][2]=new Integer(as.nominalCounts[i]);
      data[i][3]=new Double(Utils.doubleToString(as.nominalWeights[i],3));
    }
    m_StatsTable.setModel(new DefaultTableModel(data,colNames));
    m_StatsTable.getColumnModel().getColumn(0).setMaxWidth(60);
    DefaultTableCellRenderer tempR=new DefaultTableCellRenderer();
    tempR.setHorizontalAlignment(JLabel.RIGHT);
    m_StatsTable.getColumnModel().getColumn(0).setCellRenderer(tempR);
  }
 else   if (as.numericStats != null) {
    Object[] colNames={"Statistic","Value"};
    Object[][] data=new Object[4][2];
    data[0][0]="Minimum";
    data[0][1]=Utils.doubleToString(as.numericStats.min,3);
    data[1][0]="Maximum";
    data[1][1]=Utils.doubleToString(as.numericStats.max,3);
    data[2][0]="Mean" + ((!m_allEqualWeights) ? " (weighted)" : "");
    data[2][1]=Utils.doubleToString(as.numericStats.mean,3);
    data[3][0]="StdDev" + ((!m_allEqualWeights) ? " (weighted)" : "");
    data[3][1]=Utils.doubleToString(as.numericStats.stdDev,3);
    m_StatsTable.setModel(new DefaultTableModel(data,colNames));
  }
 else {
    m_StatsTable.setModel(new DefaultTableModel());
  }
  m_StatsTable.getColumnModel().setColumnMargin(4);
}