javax.swing.table.TableColumnModel.getColumnMargin()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中javax.swing.table.TableColumnModel.getColumnMargin()方法的一些代码示例,展示了TableColumnModel.getColumnMargin()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableColumnModel.getColumnMargin()方法的具体详情如下:
包路径:javax.swing.table.TableColumnModel
类名称:TableColumnModel
方法名:getColumnMargin

TableColumnModel.getColumnMargin介绍

暂无

代码示例

代码示例来源:origin: alibaba/druid

public void setColumnMargin() {
  if (columnGroups == null) {
    return;
  }
  int columnMargin = getColumnModel().getColumnMargin();
  Enumeration<ColumnGroup> enum1 = columnGroups.elements();
  while (enum1.hasMoreElements()) {
    ColumnGroup cGroup = (ColumnGroup) enum1.nextElement();
    cGroup.setColumnMargin(columnMargin);
  }
}

代码示例来源:origin: alibaba/druid

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());
}

代码示例来源:origin: alibaba/druid

Rectangle cellRect = new Rectangle(0, 0, size.width, size.height);
Hashtable<ColumnGroup, Rectangle> h = new Hashtable<ColumnGroup, Rectangle>();
int columnMargin = header.getColumnModel().getColumnMargin();
Enumeration<TableColumn> enumeration = header.getColumnModel().getColumns();
while (enumeration.hasMoreElements()) {

代码示例来源:origin: marytts/marytts

public static int getMaxColumnWidth(JTable table, int column) {
  // Set first to column header width as a minimum
  Font font = table.getFont();
  FontMetrics metrics = table.getGraphics().getFontMetrics(font);
  String header = table.getColumnName(column) + "   "; // Whitespace buffer as a crude way (hack)
                              // to account for the rendering context
  Test.output("Column name: " + header);
  // Convert from string length in characters to pixels
  int widest = metrics.stringWidth(header) + (2 * table.getColumnModel().getColumnMargin());
  Test.output("Starting widest value: " + header + " (" + widest + " pixels)");
  // Now go through each row to see if there is a longer value in the column
  int rows = table.getRowCount();
  Test.output("Row count: " + rows);
  for (int index = 0; index < rows; index++) {
    String cellValue = table.getValueAt(index, column).toString();
    int cellWidth = metrics.stringWidth(cellValue) + (2 * table.getColumnModel().getColumnMargin());
    if (cellWidth > widest) {
      widest = cellWidth;
      Test.output("New widest value: " + widest + " pixels");
    }
  }
  return widest;
}

代码示例来源:origin: com.alibaba/druid

public void setColumnMargin() {
  if (columnGroups == null) {
    return;
  }
  int columnMargin = getColumnModel().getColumnMargin();
  Enumeration<ColumnGroup> enum1 = columnGroups.elements();
  while (enum1.hasMoreElements()) {
    ColumnGroup cGroup = (ColumnGroup) enum1.nextElement();
    cGroup.setColumnMargin(columnMargin);
  }
}

代码示例来源:origin: com.alibaba/druid

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());
}

代码示例来源:origin: com.alibaba/druid

Rectangle cellRect = new Rectangle(0, 0, size.width, size.height);
Hashtable<ColumnGroup, Rectangle> h = new Hashtable<ColumnGroup, Rectangle>();
int columnMargin = header.getColumnModel().getColumnMargin();
Enumeration<TableColumn> enumeration = header.getColumnModel().getColumns();
while (enumeration.hasMoreElements()) {

代码示例来源:origin: stackoverflow.com

int columnMargin = getColumnModel().getColumnMargin();
for (ColumnGroup group : columnGroups) {
  group.setColumnMargin(columnMargin);

代码示例来源:origin: stackoverflow.com

width += columnModel.getColumnMargin() * columnModel.getColumnCount();
if (width > Integer.MAX_VALUE) {
  width = Integer.MAX_VALUE;

代码示例来源:origin: com.eas.platypus/platypus-js-grid

@Override
public void columnMarginChanged(ChangeEvent e) {
  Object oSource = e.getSource();
  assert oSource == delegate;
  int oldMargin = columnMargin;
  columnMargin = delegate.getColumnMargin();
  // Swing fires columnMarginChanged event when any column's width changes
  // this fact has no any reason. It seems that it's simply bad work of swing's programmers.
  // So, we have no any outgo, but unconditionally fire this event too.
  //if (oldMargin != columnMargin) {
  fireColumnMarginChanged(columnMargin);
  //}
}

代码示例来源:origin: com.eas.platypus/platypus-js-grid

@Override
public void columnMarginChanged(ChangeEvent e) {
  Object oSource = e.getSource();
  assert oSource == delegate;
  int oldMargin = columnMargin;
  columnMargin = delegate.getColumnMargin();
  // Swing fires columnMarginChanged event when any column's width changes
  // this fact has no any reason. It seems that it's simply bad work of swing's programmers.
  // So, we have no any outgo, but unconditionally fire this event too.
  //if (oldMargin != columnMargin) {
  fireColumnMarginChanged(columnMargin);
  //}
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * Returns the margin between columns.
 * <p>
 * 
 * Convenience to expose column model properties through
 * <code>JXTable</code> api.
 * 
 * @return the margin between columns
 * 
 * @see #setColumnMargin(int)
 * @see TableColumnModel#getColumnMargin()
 */
public int getColumnMargin() {
  return getColumnModel().getColumnMargin();
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

/**
 * Returns the margin between columns.
 * <p>
 * 
 * Convenience to expose column model properties through
 * <code>JXTable</code> api.
 * 
 * @return the margin between columns
 * 
 * @see #setColumnMargin(int)
 * @see TableColumnModel#getColumnMargin()
 */
public int getColumnMargin() {
  return getColumnModel().getColumnMargin();
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

/**
 * Returns the margin between columns.
 * <p>
 * 
 * Convenience to expose column model properties through
 * <code>JXTable</code> api.
 * 
 * @return the margin between columns
 * 
 * @see #setColumnMargin(int)
 * @see TableColumnModel#getColumnMargin()
 */
public int getColumnMargin() {
  return getColumnModel().getColumnMargin();
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
 * Returns the margin between columns.
 * <p>
 * 
 * Convenience to expose column model properties through
 * <code>JXTable</code> api.
 * 
 * @return the margin between columns
 * 
 * @see #setColumnMargin(int)
 * @see TableColumnModel#getColumnMargin()
 */
public int getColumnMargin() {
  return getColumnModel().getColumnMargin();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

void setRenderer(Component c, int o, int w) {
  impl = c;
  offset = o;
  prefWidth = w;
  
  marginOffset = isLeadingAlign(impl) ? 0 : 
          getColumnModel().getColumnMargin();
  
  implM = c instanceof Movable ? (Movable)c : null;
}

代码示例来源:origin: senbox-org/snap-desktop

void setModel(TableModel tableModel) {
  table.setModel(tableModel);
  if (table.getColumnCount() > 0) {
    final JTableHeader tableHeader = table.getTableHeader();
    final int margin = tableHeader.getColumnModel().getColumnMargin();
    final TableCellRenderer renderer = tableHeader.getDefaultRenderer();
    final Enumeration<TableColumn> columns = table.getColumnModel().getColumns();
    while (columns.hasMoreElements()) {
      TableColumn tableColumn = columns.nextElement();
      final int width = getColumnMinWith(tableColumn, renderer, margin);
      tableColumn.setMinWidth(width);
    }
  }
}

代码示例来源:origin: bcdev/beam

void setModel(TableModel tableModel) {
  table.setModel(tableModel);
  if (table.getColumnCount() > 0) {
    final JTableHeader tableHeader = table.getTableHeader();
    final int margin = tableHeader.getColumnModel().getColumnMargin();
    final TableCellRenderer renderer = tableHeader.getDefaultRenderer();
    final Enumeration<TableColumn> columns = table.getColumnModel().getColumns();
    while (columns.hasMoreElements()) {
      TableColumn tableColumn = columns.nextElement();
      final int width = getColumnMinWith(tableColumn, renderer, margin);
      tableColumn.setMinWidth(width);
    }
  }
}

代码示例来源:origin: net.sf.jga/jga

protected void paintComponent(Graphics g) {
  // TODO: this is naive: we should take the clipping region into account and
  // only paint the visible rows
  
  Rectangle cellRect = new Rectangle(0,0,getWidth(),_table.getRowHeight(0));
  int rowMargin = _header.getColumnModel().getColumnMargin() - 1;
  for (int i = 0; i < _table.getRowCount(); ++i) {
    int rowHeight = _table.getRowHeight(i);
    cellRect.height = rowHeight - rowMargin;
    paintCell(g, cellRect, i);
    cellRect.y += rowHeight;
  }
}

代码示例来源:origin: de.sciss/jtreetable

protected void layoutTree() {
  int hier = treeTable.getHierarchicalColumn();
  if (hier < 0) {
    tree.setBounds(0, 0, 0, 0);
  } else {
    Rectangle r = table.getCellRect(-1, hier, true);
    int cm = treeTable.getColumnModel().getColumnMargin();
    r.x += cm/2;
    r.width -= cm;
    r.height = treeTable.getHeight();
    tree.setBounds(r);
  }
}

相关文章