Java 8 TableColumnModel - 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 TableColumnModel class.

This code example shows how to use the following methods:getColumn
 
        final SystemPropertiesTableModel properties = new SystemPropertiesTableModel();
        final SortableTable table = new SortableTable(properties);
 
        final TableColumnModel model = table.getColumnModel();
        TableColumn column = model.getColumn(0);
        column.setPreferredWidth(200);
        column = model.getColumn(1);
        column.setPreferredWidth(350);
 
        table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
        return table;
 
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getColumn, getColumnCount
    public void columnMoved(TableColumnModelEvent e) {}
     
    public void columnRemoved(TableColumnModelEvent e) {
        int index = e.getToIndex();
        TableColumnModel tcm = (TableColumnModel) e.getSource();
        if (index >= tcm.getColumnCount()) return;
        TableColumn tc = tcm.getColumn(index);
        tc.removePropertyChangeListener(this);
    } 
     
    public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e) {}
     
} 
5
CodeRank
This code example shows how to use the following methods:getColumn, getColumnCount
    } 
 
    public static void removeCols(JTable paymentTable) {
 
        TableColumnModel tcm = paymentTable.getColumnModel();
        System.out.println("getColumnCount:" + tcm.getColumnCount());
        
        if (tcm.getColumnCount() == 13) {
            paymentTable.removeColumn(tcm.getColumn(12));
        } 
        if (tcm.getColumnCount() == 12) {
            paymentTable.removeColumn(tcm.getColumn(11));
 
        } 
        if (tcm.getColumnCount() == 11) {
            paymentTable.removeColumn(tcm.getColumn(10));
        } 
         if (tcm.getColumnCount() == 10) {
            paymentTable.removeColumn(tcm.getColumn(9));
        } 

5
CodeRank
This code example shows how to use the following methods:getColumn
	SelectionTable(Icon icon)
	{ 
		setTableHeader(null);
		setModel(new SelectionTableModel(COLUMNS));
		TableColumnModel tcm = getColumnModel();
		TableColumn tc = tcm.getColumn(0);
		if (icon != null) tc.setCellRenderer(new SelectionTableRenderer(icon));
		else tc.setCellRenderer(new SelectionTableRenderer(this));
		 
		tc = tcm.getColumn(1);
		tc.setCellEditor(getDefaultEditor(Boolean.class));
		tc.setCellRenderer(getDefaultRenderer(Boolean.class));
	} 
 
	/** 
	 * Sets the groups. 
	 *  
	 * @param groups The groups to set. 
	 */ 
	void setGroups(List<GroupData> groups)
5
CodeRank
This code example shows how to use the following methods:addColumn
 
	public static void initializeTable(JTable table)
	{ 
		table.setAutoCreateColumnsFromModel(false);
		JTableHeader header = table.getTableHeader();
		TableColumnModel columns = new DefaultTableColumnModel();
		TableCellRenderer headerRenderer = header.getDefaultRenderer();
		columns.addColumn(Utilities.createTableColumn(0, "in_level", headerRenderer, false));
		columns.addColumn(Utilities.createTableColumn(1, "in_class", headerRenderer, true));
		TableColumn remainCol = Utilities.createTableColumn(2, "in_iskRemain", headerRenderer, false);
		remainCol.setCellRenderer(new BoldNumberRenderer());
		columns.addColumn(remainCol);
		columns.addColumn(Utilities.createTableColumn(3, "in_gained", headerRenderer, false));
		table.setDefaultRenderer(Integer.class,
			new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
		table.setColumnModel(columns);
		table.setFocusable(false);
		header.setReorderingAllowed(false);
		header.setResizingAllowed(false);
	} 
 
5
CodeRank
This code example shows how to use the following methods:getColumn
 
        tableModel = new GeneralTableModel();
        table.setModel( tableModel );
 
        TableColumnModel columnModel = table.getColumnModel();
        columnModel.getColumn( 0 ).setPreferredWidth( 90 );
        columnModel.getColumn( 1 ).setPreferredWidth( 550 );
    } 
 
    private void clear() 
    { 
        tableModel.clear();
    } 
 
    @Override 
    protected void setDescriptor( Object objectDesciptor ) 
    { 
        clear(); 
        tableModel.reload( objectDesciptor );
    } 
5
CodeRank
This code example shows how to use the following methods:addColumn
        dialog.dispose();
    } 
 
    @Test
    public void testTableHeaderExists() throws Exception {
        TableColumnModel model = new DefaultTableColumnModel();
        TableColumn column = new TableColumn(0);
        column.setIdentifier("header_name");
        model.addColumn(column);
        JTableHeader tableHeader = new JTableHeader(model);
        MTableHeaderItem header = new MTableHeaderItem(tableHeader, "table_name", "header_name", null, WindowMonitor.getInstance());
        assertEquals("header_name", header.getText());
    } 
 
    @Test
    public void testClick() { 
        MTableHeaderItem mheader = new MTableHeaderItem(dialog.getTable().getTableHeader(), "table.name.header", "col2", null,
                WindowMonitor.getInstance()); 
        mheader.click(1, false);
        assertEquals(result, "col2");
5
CodeRank
This code example shows how to use the following methods:addColumn
    public void setStarTable( StarTable startable, boolean rowHeader ) {
        setModel( new StarTableModel( startable, rowHeader ) );
        this.startable = startable;
 
        /* Set up the column and column model. */ 
        TableColumnModel tcm = new DefaultTableColumnModel();
        int jcol = 0;
 
        /* Construct a dummy column for the index entries if required. */ 
        if ( rowHeader ) {
            ColumnInfo rhColInfo = new ColumnInfo( new DefaultValueInfo(
                "Index", Integer.class, "Row index" ) );
            TableColumn rhcol = new StarTableColumn( rhColInfo, jcol++ );
            rhcol.setCellRenderer( getRowHeaderRenderer() );
            tcm.addColumn( rhcol );
        } 
 
        /* Construct proper columns for the entries from the StarTable. */ 
        for ( int icol = 0; icol < startable.getColumnCount(); icol++ ) {
            ColumnInfo cinfo = startable.getColumnInfo( icol );

5
CodeRank
This code example shows how to use the following methods:getColumn
This code example shows how to use the following methods:getColumn, getColumnCount
See Code Examples for Java 8 TableColumnModel Methods: