Example usage for javax.swing JTable getColumnModel

List of usage examples for javax.swing JTable getColumnModel

Introduction

In this page you can find the example usage for javax.swing JTable getColumnModel.

Prototype

public TableColumnModel getColumnModel() 

Source Link

Document

Returns the TableColumnModel that contains all column information of this table.

Usage

From source file:vista.ventas.DiagOrdenesDeCompra.java

private void configurarTabla(JTable tbl) {
    JViewport scroll = (JViewport) tbl.getParent();
    int ancho = scroll.getWidth();
    int anchoColumna = 0;
    TableColumnModel modeloColumna = tbl.getColumnModel();
    TableColumn columnaTabla;// w  ww  . j a va  2 s .  c o  m
    for (int i = 0; i < tbl.getColumnCount(); i++) {
        columnaTabla = modeloColumna.getColumn(i);
        switch (i) {
        case 0:
            anchoColumna = (1 * ancho) / 100;
            break;
        case 1:
            anchoColumna = (20 * ancho) / 100;
            break;
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
        case 12:
            anchoColumna = (5 * ancho) / 100;
            break;
        }
        columnaTabla.setPreferredWidth(anchoColumna);
        tbl.setColumnModel(modeloColumna);
    }
    tbl.getTableHeader().setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10));
    tbl.getTableHeader().setBackground(java.awt.Color.WHITE);
    tbl.getTableHeader().setForeground(Color.BLACK);
    tbl.getTableHeader().setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 18));
    //Si le queremos cambiar el tamao a la tablita
    tbl.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 18));
}

From source file:vista.ventas.DialogEntregas.java

private void configurarTabla(JTable tbl) {
    JViewport scroll = (JViewport) tbl.getParent();
    int ancho = scroll.getWidth();
    int anchoColumna = 0;
    TableColumnModel modeloColumna = tbl.getColumnModel();
    TableColumn columnaTabla;/*from   w  ww .j  a va  2  s  .c om*/
    for (int i = 0; i < tbl.getColumnCount(); i++) {
        columnaTabla = modeloColumna.getColumn(i);
        switch (i) {
        case 0:
            anchoColumna = 1 / 100;
            break;
        case 1:
            anchoColumna = (20 * ancho) / 100;
            break;
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
        case 12:
            anchoColumna = (5 * ancho) / 100;
            break;
        }
        columnaTabla.setPreferredWidth(anchoColumna);
        tbl.setColumnModel(modeloColumna);
    }
    tbl.getTableHeader().setBackground(java.awt.Color.WHITE);
    tbl.getTableHeader().setForeground(Color.BLACK);
    tbl.getTableHeader().setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 14));
    //Si le queremos cambiar el tamao a la tablita
    tbl.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 14));
}