Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.swing.JTable;

public class Main {
    /**
     * Returns the visual height of the given table.
     *
     * @param table the table.
     *
     * @return the table height.
     */
    public static int getTableHeight(JTable table) {
        int result = 0;
        int rowHeight = 0;

        for (int i = 0, rows = table.getRowCount(); i < rows; i++) {
            int height = table.getRowHeight(i);
            result += height;

            if (height > rowHeight) {
                rowHeight = height;
            }
        }

        return result + rowHeight + (table.getRowCount() * table.getRowMargin());
    }
}