List of usage examples for weka.gui JTableHelper setOptimalHeaderWidth
public static void setOptimalHeaderWidth(JTable jtable, int col)
From source file:meka.gui.dataviewer.DataTable.java
License:Open Source License
/** * sets the cell renderer and calcs the optimal column width *///w ww .j a v a 2 s .co m private void setLayout() { DataSortedTableModel arffModel; int i; JComboBox combo; Enumeration<Object> enm; arffModel = (DataSortedTableModel) getModel(); for (i = 0; i < getColumnCount(); i++) { // optimal colwidths (only according to header!) JTableHelper.setOptimalHeaderWidth(this, i); // CellRenderer getColumnModel().getColumn(i).setCellRenderer(new DataTableCellRenderer()); // CellEditor if (i > 0) { if (arffModel.getType(i) == Attribute.NOMINAL) { combo = new JComboBox(); combo.addItem(null); enm = arffModel.getInstances().attribute(i - 1).enumerateValues(); while (enm.hasMoreElements()) { Object o = enm.nextElement(); if (o instanceof SerializedObject) { ((SerializedObject) o).getObject(); } combo.addItem(o); } getColumnModel().getColumn(i).setCellEditor(new DefaultCellEditor(combo)); } else { getColumnModel().getColumn(i).setCellEditor(null); } } } }