Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.table
Class TableCellResizer

java.lang.Object
  extended by com.citra.table.TableCellResizer

public class TableCellResizer
extends Object

TableCellResizer adds cell-resizing functionality to a JTable.


Field Summary
static int COLUMN_RESIZE
          integer indicating that the column will be resized to its contents should the user double-click on its border
protected  int columnMargin
          the pixels to add to the columns that are resized
protected  boolean columnResizingEnabled
          flag indicating whether column resizing is enabled
static int DEFAULT_COLUMN_MARGIN
          the default column margin
protected  int minRowHeight
          the minimum row height a row is allowed to resize to
static int NO_RESIZE
          integer indicating that nothing will happen should the user double-click on a column border
protected  boolean resizeAllColumns
          flag indicating whether all columns will be resized to the resizing column
protected  boolean resizeAllRows
          flag indicating whether all rows will be resized to the resizing row
protected  int resizeMode
          the resize mode
static int ROW_COLUMN_RESIZE
          integer indicating that both row and column will be resized to its contents should the user double-click on its border
static int ROW_RESIZE
          integer indicating that the row will be resized to its contents should the user double-click on its border
protected  boolean rowResizingEnabled
          flag indicating whether row resizing is enabled
protected  JTable table
          the associated table
 
Constructor Summary
TableCellResizer(JTable table)
          Constructs a TableCellResizer.
 
Method Summary
protected  boolean canResizeColumn(int columnIndex)
          Returns true if the column is allowed to be resized.
protected  boolean canResizeRow(int row)
          Returns true if the row is allowed to be resized.
 boolean check(MouseEvent e)
          Processes the mouse event and determines whether the table is being resized.
 int getColumnMargin()
          Determines the pixels to increase the width of a column by, when it is being automatically resized with the TableCellResizer.resizeColumnToContents(int) method.
 boolean getColumnResizingEnabled()
          Determines whether column resizing is enabled.
 int getMinRowHeight()
          Determines the minimum row height a row is allowed to be resized to.
 boolean getResizeAllColumns()
          Determines whether all columns will be resized to the resizing column.
 boolean getResizeAllRows()
          Determines whether all rows will be resized to the resizing row.
 int getResizeMode()
          Determines the current resize mode, when a user double clicks on a cell border.
 boolean getRowResizingEnabled()
          Determines whether row resizing is enabled.
 JTable getTable()
          Returns the associated table.
 void resizeColumnsToContents()
          Resizes all columns to their contents.
 void resizeColumnToContents(int column)
          Resizes a column to its contents.
 void resizeRowsToContents()
          Resizes all rows to their contents.
 void resizeRowToContents(int row)
          Resizes a row to its contents.
 void setColumnMargin(int columnMargin)
          Assigns the pixels to increase the width of a column by, when it is being automatically resized with the TableCellResizer.resizeColumnToContents(int) method.
 void setColumnResizingEnabled(boolean columnResizingEnabled)
          Determines whether column resizing is enabled.
 void setMinRowHeight(int minRowHeight)
          Determines the minimum row height a row is allowed to be resized to.
 void setResizeAllColumns(boolean resizeAllColumns)
          Determines whether all columns will be resized to the resizing column.
 void setResizeAllRows(boolean resizeAllRows)
          Determines whether all rows will be resized to the resizing row.
 void setResizeMode(int resizeMode)
          Assigns the resize mode, when a user double clicks on a cell border.
 void setRowResizingEnabled(boolean rowResizingEnabled)
          Determines whether row resizing is enabled.
 void setTable(JTable table)
          Assigns the table to be resized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resizeAllRows

protected boolean resizeAllRows
flag indicating whether all rows will be resized to the resizing row


resizeAllColumns

protected boolean resizeAllColumns
flag indicating whether all columns will be resized to the resizing column


table

protected JTable table
the associated table


rowResizingEnabled

protected boolean rowResizingEnabled
flag indicating whether row resizing is enabled


columnResizingEnabled

protected boolean columnResizingEnabled
flag indicating whether column resizing is enabled


minRowHeight

protected int minRowHeight
the minimum row height a row is allowed to resize to


NO_RESIZE

public static final int NO_RESIZE
integer indicating that nothing will happen should the user double-click on a column border

See Also:
Constant Field Values

ROW_RESIZE

public static final int ROW_RESIZE
integer indicating that the row will be resized to its contents should the user double-click on its border

See Also:
Constant Field Values

COLUMN_RESIZE

public static final int COLUMN_RESIZE
integer indicating that the column will be resized to its contents should the user double-click on its border

See Also:
Constant Field Values

ROW_COLUMN_RESIZE

public static final int ROW_COLUMN_RESIZE
integer indicating that both row and column will be resized to its contents should the user double-click on its border

See Also:
Constant Field Values

resizeMode

protected int resizeMode
the resize mode


DEFAULT_COLUMN_MARGIN

public static final int DEFAULT_COLUMN_MARGIN
the default column margin

See Also:
Constant Field Values

columnMargin

protected int columnMargin
the pixels to add to the columns that are resized

Constructor Detail

TableCellResizer

public TableCellResizer(JTable table)
Constructs a TableCellResizer.

Method Detail

canResizeColumn

protected boolean canResizeColumn(int columnIndex)
Returns true if the column is allowed to be resized.

Parameters:
columnIndex - the column
Returns:
true if column is allowed to be resized, false otherwise

canResizeRow

protected boolean canResizeRow(int row)
Returns true if the row is allowed to be resized.

Parameters:
row - the row
Returns:
true if row is allowed to be resized, false otherwise

check

public boolean check(MouseEvent e)
Processes the mouse event and determines whether the table is being resized.

Parameters:
e - the mouse event
Returns:
true if the table is resizing, false otherwise

getColumnMargin

public int getColumnMargin()
Determines the pixels to increase the width of a column by, when it is being automatically resized with the TableCellResizer.resizeColumnToContents(int) method.

Returns:
the number of pixels

getColumnResizingEnabled

public boolean getColumnResizingEnabled()
Determines whether column resizing is enabled.

Returns:
true if column resizing is enabled, false otherwise

getMinRowHeight

public int getMinRowHeight()
Determines the minimum row height a row is allowed to be resized to.

Returns:
the minimum row height

getResizeAllColumns

public boolean getResizeAllColumns()
Determines whether all columns will be resized to the resizing column.

Returns:
true if all columns will be resized to the resizing column, false otherwise

getResizeAllRows

public boolean getResizeAllRows()
Determines whether all rows will be resized to the resizing row.

Returns:
true if all rows will be resized to the resizing row, false otherwise

getResizeMode

public int getResizeMode()
Determines the current resize mode, when a user double clicks on a cell border.

The mode may be:
NO_RESIZE: nothing will happen
ROW_RESIZE: row will be resized to its contents
COLUMN_RESIZE: column will be resized to its contents
ROW_COLUMN_RESIZE: both row and column will be resized to its contents

The default mode is ROW_COLUMN_RESIZE.

Returns:
the resize mode

getRowResizingEnabled

public boolean getRowResizingEnabled()
Determines whether row resizing is enabled.

Returns:
true if row resizing is enabled, false otherwise

getTable

public JTable getTable()
Returns the associated table.

Returns:
the associated table

resizeColumnsToContents

public void resizeColumnsToContents()
Resizes all columns to their contents.


resizeColumnToContents

public void resizeColumnToContents(int column)
Resizes a column to its contents.

Parameters:
column - the column to be resized

resizeRowsToContents

public void resizeRowsToContents()
Resizes all rows to their contents.


resizeRowToContents

public void resizeRowToContents(int row)
Resizes a row to its contents.

Parameters:
row - the row to be resized

setColumnMargin

public void setColumnMargin(int columnMargin)
Assigns the pixels to increase the width of a column by, when it is being automatically resized with the TableCellResizer.resizeColumnToContents(int) method.

Parameters:
columnMargin - the number of pixels

setColumnResizingEnabled

public void setColumnResizingEnabled(boolean columnResizingEnabled)
Determines whether column resizing is enabled.

Parameters:
columnResizingEnabled - true if column resizing is enabled, false otherwise

setMinRowHeight

public void setMinRowHeight(int minRowHeight)
Determines the minimum row height a row is allowed to be resized to.

Parameters:
minRowHeight - the minimum row height

setResizeAllColumns

public void setResizeAllColumns(boolean resizeAllColumns)
Determines whether all columns will be resized to the resizing column.

Parameters:
resizeAllColumns - true if all columns will be resized to the resizing column, false otherwise

setResizeAllRows

public void setResizeAllRows(boolean resizeAllRows)
Determines whether all rows will be resized to the resizing row.

Parameters:
resizeAllRows - true if all rows will be resized to the resizing row, false otherwise

setResizeMode

public void setResizeMode(int resizeMode)
Assigns the resize mode, when a user double clicks on a cell border.

The mode may be:
NO_RESIZE: nothing will happen
ROW_RESIZE: row will be resized to its contents
COLUMN_RESIZE: column will be resized to its contents
ROW_COLUMN_RESIZE: both row and column will be resized to its contents

The default mode is ROW_COLUMN_RESIZE.

Parameters:
resizeMode - the resize mode

setRowResizingEnabled

public void setRowResizingEnabled(boolean rowResizingEnabled)
Determines whether row resizing is enabled.

Parameters:
rowResizingEnabled - true if row resizing is enabled, false otherwise

setTable

public void setTable(JTable table)
Assigns the table to be resized.

Parameters:
table - the associated table

Copyright © 2011 Citra Technologies. All Rights Reserved.