All Downloads are FREE. Search and download functionalities are using the official Maven repository.

decodes.gui.TableColumnAdjuster Maven / Gradle / Ivy

Go to download

A collection of software for aggregatting and processing environmental data such as from NOAA GOES satellites.

The newest version!
package decodes.gui;

import javax.swing.*;
import javax.swing.table.*;

/**
Static utility to adjust column widths.
*/
public class TableColumnAdjuster
{
	/**
	 * Adjusts widths of the table according to percentages that you supply
	 * in an array.
	 * @param table the JTable
	 * @param percent array of integers, one for each column.
	 */
	public static void adjustColumnWidths(JTable table, int[] percent)
	{
		int totalWidth = 0;
		TableColumn tc[] = new TableColumn[percent.length];

//		tableWidth = table.getWidth();
		// Get total width of all columns
		for(int i=0; i= 0; i--)
		{
			int w = (int)(totalWidth * (double)percent[i]/100.0);
			tc[i].setPreferredWidth(w);
			tc[i].setWidth(w);
		}
		
		
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy