register JTable Column Size Listener - Java Swing

Java examples for Swing:JTable Column

Description

register JTable Column Size Listener

Demo Code


//package com.java2s;

import java.beans.PropertyChangeListener;
import java.util.Enumeration;

import javax.swing.JTable;

import javax.swing.table.TableColumn;

public class Main {
    public static void registerColumnSizeListener(JTable table,
            PropertyChangeListener listener) {
        for (Enumeration<TableColumn> columns = table.getColumnModel()
                .getColumns(); columns.hasMoreElements();) {
            TableColumn column = columns.nextElement();
            column.addPropertyChangeListener(listener);
        }/*  w  w w .j a  v  a2  s  . c  o m*/
    }
}

Related Tutorials