Example usage for javax.swing JTable getColumnCount

List of usage examples for javax.swing JTable getColumnCount

Introduction

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

Prototype

@BeanProperty(bound = false)
public int getColumnCount() 

Source Link

Document

Returns the number of columns in the column model.

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;// ww  w  .j  a v a  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 www  .j a  v a 2s.c  o m
    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));
}