Java Code Examples for javax.swing.table.TableColumn#sizeWidthToFit()

The following examples show how to use javax.swing.table.TableColumn#sizeWidthToFit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utilities.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static TableColumn createTableColumn(int index, String headerValue, TableCellRenderer headerRenderer,
	boolean resizable)
{
	TableColumn column = new TableColumn(index);
	if (headerValue.startsWith("in_"))
	{
		column.setHeaderValue(LanguageBundle.getString(headerValue));
	}
	else
	{
		column.setHeaderValue(headerValue);
	}
	column.setHeaderRenderer(headerRenderer);
	if (!resizable)
	{
		column.sizeWidthToFit();
		column.setMaxWidth(column.getMaxWidth() + 10);
		column.setPreferredWidth(column.getPreferredWidth() + 10);
	}
	column.setResizable(resizable);
	return column;
}
 
Example 2
Source File: Utilities.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static TableColumn createTableColumn(int index, String headerValue, TableCellRenderer headerRenderer,
	boolean resizable)
{
	TableColumn column = new TableColumn(index);
	if (headerValue.startsWith("in_"))
	{
		column.setHeaderValue(LanguageBundle.getString(headerValue));
	}
	else
	{
		column.setHeaderValue(headerValue);
	}
	column.setHeaderRenderer(headerRenderer);
	if (!resizable)
	{
		column.sizeWidthToFit();
		column.setMaxWidth(column.getMaxWidth() + 10);
		column.setPreferredWidth(column.getPreferredWidth() + 10);
	}
	column.setResizable(resizable);
	return column;
}
 
Example 3
Source File: SorterTableColumnModel.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private TableColumn makeTableColumn(int x, Sortables c) {
    TableColumn tc = new TableColumn(x);
    FBTableCellRenderer temp = new FBTableCellRenderer();
    tc.setHeaderRenderer(temp);
    tc.setIdentifier(c);
    tc.setHeaderValue(c);
    tc.setResizable(false);
    tc.sizeWidthToFit();
    return tc;
}
 
Example 4
Source File: DiagnosticsForThreads.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
public DiagnosticsForThreads() {

    JTable table = new JTable(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);

    // code added Feb 2014 by Doug Brown
  	FontSizer.setFonts(table, FontSizer.getLevel());
  	Font font = table.getFont();
  	table.setRowHeight(font.getSize()+4);
  	table.getTableHeader().setFont(font);
    // end added code

    TableColumnModel colModel = table.getColumnModel();
    int numColumns = colModel.getColumnCount();

    for (int i = 0; i < numColumns - 1; i++) {
      TableColumn col = colModel.getColumn(i);

      col.sizeWidthToFit();
      col.setPreferredWidth(col.getWidth() + 5);
      col.setMaxWidth(col.getWidth() + 5);
    }

    JScrollPane sp = new JScrollPane(table);

    setLayout(new BorderLayout());
    add(sp, BorderLayout.CENTER);
  }
 
Example 5
Source File: SimpleStyleEditorPanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void applyHeaderSize( final TableColumn col ) {
  col.setHeaderRenderer( new DefaultTableHeaderRenderer() );
  col.sizeWidthToFit();
}
 
Example 6
Source File: StyleEditorPanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void applyHeaderSize( final TableColumn col ) {
  col.setHeaderRenderer( new DefaultTableHeaderRenderer() );
  col.sizeWidthToFit();
}
 
Example 7
Source File: VisualAttributeEditorPanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void applyHeaderSize( final TableColumn col ) {
  col.setHeaderRenderer( new DefaultTableHeaderRenderer() );
  col.sizeWidthToFit();
}