本文整理匯總了Java中javax.swing.table.TableColumnModel.getColumnMargin方法的典型用法代碼示例。如果您正苦於以下問題:Java TableColumnModel.getColumnMargin方法的具體用法?Java TableColumnModel.getColumnMargin怎麽用?Java TableColumnModel.getColumnMargin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.table.TableColumnModel
的用法示例。
在下文中一共展示了TableColumnModel.getColumnMargin方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateTableColumnSizes
import javax.swing.table.TableColumnModel; //導入方法依賴的package包/類
private void updateTableColumnSizes() {
ETable table = tableView.getTable();
Font font = tableView.getFont();
FontMetrics fm = tableView.getFontMetrics(font);
int maxCharWidth = fm.charWidth('A');
int editingBorder = 4;
TableColumnModel columnModel = table.getColumnModel();
TableColumn nameColumn = columnModel.getColumn(0);
nameColumn.setPreferredWidth(8 * maxCharWidth + editingBorder); // 8 chars for name
TableColumn keyColumn = columnModel.getColumn(1);
// Single char for key (but 3 chars to prevent "..." in column header)
keyColumn.setPreferredWidth(3 * maxCharWidth + editingBorder);
keyColumn.setMinWidth(keyColumn.getPreferredWidth());
TableColumn locationColumn = columnModel.getColumn(2);
Insets insets = tableView.getBorder().getBorderInsets(tableView);
int remainingWidth = tableView.getParent().getWidth() - insets.left - insets.right;
remainingWidth -= 2 * columnModel.getColumnMargin();
remainingWidth -= nameColumn.getPreferredWidth();
remainingWidth -= keyColumn.getPreferredWidth();
locationColumn.setPreferredWidth(remainingWidth); // remaining space for location
}
示例2: createHeaderSize
import javax.swing.table.TableColumnModel; //導入方法依賴的package包/類
/**
* Calculate and return the dimension of the header.
*
* @param width Starting width to be used.
* @return Dimension of the header
*/
private Dimension createHeaderSize(long width) {
TableColumnModel columnModel = header.getColumnModel();
width += columnModel.getColumnMargin() * columnModel.getColumnCount();
if (width > Integer.MAX_VALUE) {
width = Integer.MAX_VALUE;
}
return new Dimension((int) width, getHeaderHeight());
}
示例3: paintCells
import javax.swing.table.TableColumnModel; //導入方法依賴的package包/類
/**
* (copy & paste from BasicTableUI)
*/
private void paintCells(Graphics g, int rMin, int rMax, int cMin, int cMax) {
JTableHeader header = table.getTableHeader();
TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();
TableColumnModel cm = table.getColumnModel();
int columnMargin = cm.getColumnMargin();
Rectangle cellRect;
TableColumn aColumn;
int columnWidth;
if (table.getComponentOrientation().isLeftToRight()) {
for(int row = rMin; row <= rMax; row++) {
cellRect = table.getCellRect(row, cMin, false);
if( isFoldingRow( row ) ) {
//paint the cell across the whole table
cellRect.x = 0;
cellRect.width = table.getColumnModel().getTotalColumnWidth()-columnMargin;
paintCell( g, cellRect, row, 0 );
} else {
for(int column = cMin; column <= cMax; column++) {
aColumn = cm.getColumn(column);
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth - columnMargin;
if (aColumn != draggedColumn) {
paintCell(g, cellRect, row, column);
}
cellRect.x += columnWidth;
}
}
}
} else {
for(int row = rMin; row <= rMax; row++) {
cellRect = table.getCellRect(row, cMin, false);
if( isFoldingRow( row ) ) {
//paint the cell across the whole table
cellRect.x = 0;
cellRect.width = table.getColumnModel().getTotalColumnWidth()-columnMargin;
paintCell( g, cellRect, row, 0 );
} else {
aColumn = cm.getColumn(cMin);
if (aColumn != draggedColumn) {
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth - columnMargin;
paintCell(g, cellRect, row, cMin);
}
for(int column = cMin+1; column <= cMax; column++) {
aColumn = cm.getColumn(column);
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth - columnMargin;
cellRect.x -= columnWidth;
if (aColumn != draggedColumn) {
paintCell(g, cellRect, row, column);
}
}
}
}
}
// Paint the dragged column if we are dragging.
if (draggedColumn != null) {
paintDraggedArea(g, rMin, rMax, draggedColumn, header.getDraggedDistance());
}
// Remove any renderers that may be left in the rendererPane.
rendererPane.removeAll();
}
示例4: paintCells
import javax.swing.table.TableColumnModel; //導入方法依賴的package包/類
private void paintCells(SynthContext context, Graphics g, int rMin,
int rMax, int cMin, int cMax) {
JTableHeader header = table.getTableHeader();
TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();
TableColumnModel cm = table.getColumnModel();
int columnMargin = cm.getColumnMargin();
Rectangle cellRect;
TableColumn aColumn;
int columnWidth;
if (table.getComponentOrientation().isLeftToRight()) {
for(int row = rMin; row <= rMax; row++) {
cellRect = table.getCellRect(row, cMin, false);
for(int column = cMin; column <= cMax; column++) {
aColumn = cm.getColumn(column);
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth - columnMargin;
if (aColumn != draggedColumn) {
paintCell(context, g, cellRect, row, column);
}
cellRect.x += columnWidth;
}
}
} else {
for(int row = rMin; row <= rMax; row++) {
cellRect = table.getCellRect(row, cMin, false);
aColumn = cm.getColumn(cMin);
if (aColumn != draggedColumn) {
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth - columnMargin;
paintCell(context, g, cellRect, row, cMin);
}
for(int column = cMin+1; column <= cMax; column++) {
aColumn = cm.getColumn(column);
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth - columnMargin;
cellRect.x -= columnWidth;
if (aColumn != draggedColumn) {
paintCell(context, g, cellRect, row, column);
}
}
}
}
// Paint the dragged column if we are dragging.
if (draggedColumn != null) {
paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
}
// Remove any renderers that may be left in the rendererPane.
rendererPane.removeAll();
}