Returns a boolean indication whether the event represents a update type in JTable. - Java Swing

Java examples for Swing:JTable Event

Description

Returns a boolean indication whether the event represents a update type in JTable.

Demo Code


//package com.java2s;

import javax.swing.event.TableModelEvent;

public class Main {
    /**/*  www . j  a  v a  2s  .  co  m*/
     * Returns a boolean indication whether the event represents a
     * update type.
     * 
     * @param e the event to examine.
     * @return true if the event is a true update, false
     *         otherwise.
     */
    public static boolean isUpdate(TableModelEvent e) {
        if (isStructureChanged(e))
            return false;
        return e.getType() == TableModelEvent.UPDATE
                && e.getLastRow() < Integer.MAX_VALUE;
    }

    /**
     * Returns a boolean indication whether the event represents a
     * structureChanged type.
     * 
     * @param e the event to examine.
     * @return true if the event is of type structureChanged or null, false
     *         else.
     */
    public static boolean isStructureChanged(TableModelEvent e) {
        return e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW;
    }
}

Related Tutorials