Java 8 DefaultTableModel - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DefaultTableModel class.

This code example shows how to use the following methods:addColumn, addRow
   * 
   * @return A <code>TableModel</code>. 
   */ 
  public static TableModel createData()
  { 
    final DefaultTableModel data = new DefaultTableModel();
    data.addColumn("Data");
    data.addColumn("A");
    data.addColumn("B");
    data.addColumn("C");
    data.addRow(new Object[]{"data.firstElement", new Double(43.0), new Double(127.5), new Double(10001.999)});
    data.addRow(new Object[]{"data.secondElement", new Double(57.0), new Double(108.5), new Double(-10001.999)});
    data.addRow(new Object[]{"data.thirdElement", new Double(35.0), new Double(164.8), new Double(-999.9999)});
    data.addRow(new Object[]{"data.fourthElement", new Double(86.0), new Double(164.0), new Double(999.9999)});
    data.addRow(new Object[]{"data.lastElement", new Double(12.0), new Double(103.2), new Double(0.999)});
    return data;
  } 
 
  public PreviewHandler getPreviewHandler() 
  { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addColumn, setValueAt
    super(name);
  } 
 
  public void testBorderCase() 
  { 
    final DefaultTableModel model = new DefaultTableModel(3, 0);
    model.addColumn("Boolean");
    model.setValueAt(Boolean.TRUE, 0, 0);
    model.setValueAt(Boolean.FALSE, 0, 0);
    model.setValueAt(Boolean.TRUE, 0, 0);
 
    final DefaultFilterTableModel filter = new DefaultFilterTableModel(model, 0);
    filter.setFilters(CompoundFilter.create(new BooleanFilter()));
    filter.mapToModel(1);
    filter.mapToModel(0);
  } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setValueAt
    ClassicEngineBoot.getInstance().start(); 
  } 
 
  public void testSelectDefault() throws ReportProcessingException 
  { 
    final DefaultTableModel tableModel = new DefaultTableModel(new String[]{"key", "value"}, 1);
    tableModel.setValueAt("key-entry", 0, 0);
    tableModel.setValueAt("value-entry", 0, 1);
 
    final DefaultListParameter listParameter =
        new DefaultListParameter("test", "key", "value", "name", false, true, String.class);
    listParameter.setParameterAutoSelectFirstValue(true);
    listParameter.setMandatory(true);
 
    final DefaultParameterDefinition definition = new DefaultParameterDefinition();
    definition.addParameterDefinition(listParameter);
 
    final MasterReport report = new MasterReport();
    report.setParameterDefinition(definition);
    report.setDataFactory(new TableDataFactory("test", tableModel));

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setValueAt
  } 
 
  public void testEventOrder() throws Exception
  { 
    final MasterReport report = getReport();
    final DefaultTableModel model = new DefaultTableModel(2, 1);
    model.setValueAt("0-0", 0, 0);
    model.setValueAt("0-1", 1, 0);
    report.setDataFactory(new TableDataFactory
        ("default", model));
 
    DebugReportRunner.executeAll(report);
  } 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addColumn, addRow
   * 
   * @return A <code>TableModel</code>. 
   */ 
  public static TableModel createData()
  { 
    final DefaultTableModel data = new DefaultTableModel();
    data.addColumn("A");
    data.addColumn("B");
    data.addRow(new Object[]{new Double(43.0), new Double(127.5)});
    data.addRow(new Object[]{new Double(57.0), new Double(108.5)});
    data.addRow(new Object[]{new Double(35.0), new Double(164.8)});
    data.addRow(new Object[]{new Double(86.0), new Double(164.0)});
    data.addRow(new Object[]{new Double(12.0), new Double(103.2)});
    return data;
  } 
 
  public static void main(final String[] args)
  { 
    ClassicEngineBoot.getInstance().start(); 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setColumnCount
/** 
 * Created by cwardgar on 1/9/14. 
 */ 
public class HidableTableColumnModelTest { 
    @Test public void testTableModelResize() {
        DefaultTableModel model = new DefaultTableModel(6, 6);
        HidableTableColumnModel tcm = new HidableTableColumnModel(model);
 
        // At start numAllColumns == numVisibleColumns. 
        Assert.assertEquals(tcm.getColumnCount(false), tcm.getColumnCount(true));
 
        tcm.setColumnVisible(tcm.getColumn(1, false), false);  // Remove column at modelIndex 1.
        tcm.setColumnVisible(tcm.getColumn(4, false), false);  // Remove column at modelIndex 4.
 
        // We've removed 2 columns. 
        Assert.assertEquals(tcm.getColumnCount(false) - 2, tcm.getColumnCount(true));
 
        model.setColumnCount(10);
        Assert.assertEquals(10, tcm.getColumnCount(true));
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:addColumn
        String msg = tr("<html>{0} relations build a cycle because they refer to each other.<br>"
                + "JOSM cannot upload them. Please edit the relations and remove the " 
                + "cyclic dependency.</html>", dep.size()-1);
        pnl.add(new JLabel(msg), BorderLayout.NORTH);
 
        DefaultTableModel model = new DefaultTableModel();
        model.addColumn(tr("Relation ..."));
        model.addColumn(tr("... refers to relation"));
        for (int i=0; i<dep.size()-1;i++) {
            Relation r1 = dep.get(i);
            Relation r2 = dep.get(i+1);
            model.addRow(new Relation[] {r1,r2});
        } 
        JTable tbl = new JTable(model);
        OsmPrimitivRenderer renderer = new OsmPrimitivRenderer();
        tbl.getColumnModel().getColumn(0).setCellRenderer(renderer);
        tbl.getColumnModel().getColumn(1).setCellRenderer(renderer);
        pnl.add(new JScrollPane(tbl), BorderLayout.CENTER);
        return pnl;
    } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getColumnCount, setColumnCount, setValueAt
	} 
 
	@Override 
	public void setValueAt(Object value, int row, int column) {
		// update column count if needed 
		if (column >= defaultTableModel.getColumnCount()) {
			defaultTableModel.setColumnCount(column + 1);
		} 
		defaultTableModel.setValueAt(value, row, column);
	} 
 
	public boolean hasFocus() { 
		App.debug("unimplemented"); 
		return false; 
	} 
 
	public void repaint() { 
		App.debug("unimplemented"); 
	} 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        JFrame jf = new JFrame("Test1");
        JWindow jw = new JWindow(jf);
        JDialog jd = new JDialog(jf);
        JPanel jp1 = new JPanel();
        JButton jb1 = new JButton("jb1");
        JTable jt1 = new JTable(new DefaultTableModel());
 
        jf.add(jb1);
        jf.add(jt1);
        jf.add(jp1);
        System.out.println("FTP current on jf= " + jf.getFocusTraversalPolicy());
        System.out.println("FTP current on jw= " + jw.getFocusTraversalPolicy());
        System.out.println("FTP current on jd= " + jd.getFocusTraversalPolicy());
 
        if (!(jf.getFocusTraversalPolicy() instanceof LayoutFocusTraversalPolicy) ||
            !(jw.getFocusTraversalPolicy() instanceof LayoutFocusTraversalPolicy) ||
            !(jd.getFocusTraversalPolicy() instanceof LayoutFocusTraversalPolicy))
        { 
            throw new RuntimeException("Failure! Swing toplevel must have LayoutFocusTraversalPolicy installed");
        } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 DefaultTableModel Methods: