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

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

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

TableColumn.getMaxWidth介绍

暂无

代码示例

代码示例来源:origin: ron190/jsql-injection

  1. /**
  2. * Calculate the width based on the widest cell renderer for the
  3. * given column.
  4. */
  5. private int getColumnDataWidth(int column) {
  6. if (! this.isColumnDataIncluded) {
  7. return 0;
  8. }
  9. int preferredWidth = 0;
  10. int maxWidth = this.tableAdjust.getColumnModel().getColumn(column).getMaxWidth();
  11. for (int row = 0 ; row < this.tableAdjust.getRowCount() ; row++) {
  12. preferredWidth = Math.max(preferredWidth, this.getCellDataWidth(row, column));
  13. // We've exceeded the maximum width, no need to check other rows
  14. if (preferredWidth >= maxWidth) {
  15. break;
  16. }
  17. }
  18. return preferredWidth;
  19. }

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

  1. JTable table = new JTable( ... );
  2. table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
  3. for (int column = 0; column < table.getColumnCount(); column++)
  4. {
  5. TableColumn tableColumn = table.getColumnModel().getColumn(column);
  6. int preferredWidth = tableColumn.getMinWidth();
  7. int maxWidth = tableColumn.getMaxWidth();
  8. for (int row = 0; row < table.getRowCount(); row++)
  9. {
  10. TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
  11. Component c = table.prepareRenderer(cellRenderer, row, column);
  12. int width = c.getPreferredSize().width + table.getIntercellSpacing().width;
  13. preferredWidth = Math.max(preferredWidth, width);
  14. // We've exceeded the maximum width, no need to check other rows
  15. if (preferredWidth >= maxWidth)
  16. {
  17. preferredWidth = maxWidth;
  18. break;
  19. }
  20. }
  21. tableColumn.setPreferredWidth( preferredWidth );
  22. }

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

  1. public int getMaxWidth() {
  2. if (tableColumn != null) {
  3. return tableColumn.getMaxWidth();
  4. } else {
  5. return maxWidth;
  6. }
  7. }

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

  1. boolean isColumnVisible(TableColumn column) {
  2. return column.getMaxWidth() > 0;
  3. }

代码示例来源:origin: xyz.cofe/gui.swing

  1. public int getMaxWidth() {
  2. return tableColumn.getMaxWidth();
  3. }

代码示例来源:origin: SKCraft/Launcher

  1. private int getColumnDataWidth(int column) {
  2. if (!isColumnDataIncluded) return 0;
  3. int preferredWidth = 0;
  4. int maxWidth = table.getColumnModel().getColumn(column).getMaxWidth();
  5. for (int row = 0; row < table.getRowCount(); row++) {
  6. preferredWidth = Math.max(preferredWidth, getCellDataWidth(row, column));
  7. // We've exceeded the maximum width, no need to check other rows
  8. if (preferredWidth >= maxWidth)
  9. break;
  10. }
  11. return preferredWidth;
  12. }

代码示例来源:origin: net.sf.kerner-utils/kerner-utils

  1. private int getColumnDataWidth(final int column) {
  2. if (!isColumnDataIncluded)
  3. return 0;
  4. int preferredWidth = 0;
  5. final int maxWidth = table.getColumnModel().getColumn(column).getMaxWidth();
  6. for (int row = 0; row < table.getRowCount(); row++) {
  7. preferredWidth = Math.max(preferredWidth, getCellDataWidth(row, column));
  8. // We've exceeded the maximum width, no need to check other rows
  9. if (preferredWidth >= maxWidth)
  10. break;
  11. }
  12. return preferredWidth;
  13. }

代码示例来源:origin: kaikramer/keystore-explorer

  1. private int getColumnDataWidth(int column) {
  2. if (!isColumnDataIncluded) {
  3. return 0;
  4. }
  5. int preferredWidth = 0;
  6. int maxWidth = table.getColumnModel().getColumn(column).getMaxWidth();
  7. for (int row = 0; row < table.getRowCount(); row++) {
  8. preferredWidth = Math.max(preferredWidth, getCellDataWidth(row, column));
  9. // We've exceeded the maximum width, no need to check other rows
  10. if (preferredWidth >= maxWidth) {
  11. break;
  12. }
  13. }
  14. return preferredWidth;
  15. }

代码示例来源:origin: bspkrs/MCPMappingViewer

  1. private int getColumnDataWidth(int column)
  2. {
  3. if (!isColumnDataIncluded)
  4. return 0;
  5. int preferredWidth = 0;
  6. int maxWidth = table.getColumnModel().getColumn(column).getMaxWidth();
  7. for (int row = 0; row < table.getRowCount(); row++)
  8. {
  9. preferredWidth = Math.max(preferredWidth, getCellDataWidth(row, column));
  10. // We've exceeded the maximum width, no need to check other rows
  11. if (preferredWidth >= maxWidth)
  12. break;
  13. }
  14. return preferredWidth;
  15. }

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javaee-project

  1. public static void updateColumnWidths(JTable table) {
  2. double pw = table.getParent().getSize().getWidth();
  3. table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
  4. TableColumn column = table.getColumnModel().getColumn(1);
  5. int w = ((int) pw / 2) - 1;
  6. if (w > column.getMaxWidth()) {
  7. w = column.getMaxWidth();
  8. }
  9. column.setWidth(w);
  10. column.setPreferredWidth(w);
  11. w = (int) pw - w;
  12. column = table.getColumnModel().getColumn(0);
  13. column.setWidth(w);
  14. column.setPreferredWidth(w);
  15. }

代码示例来源:origin: com.synaptix/SynaptixSwing

  1. /**
  2. * Return the maximum size of the header. The maximum width is the sum of
  3. * the maximum widths of each column (plus inter-cell spacing).
  4. */
  5. public Dimension getMaximumSize(JComponent c) {
  6. long width = 0;
  7. Enumeration enumeration = footer.getTable().getColumnModel()
  8. .getColumns();
  9. while (enumeration.hasMoreElements()) {
  10. TableColumn aColumn = (TableColumn) enumeration.nextElement();
  11. width = width + aColumn.getMaxWidth();
  12. }
  13. return createHeaderSize(width);
  14. }

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

  1. public void mouseDragged(MouseEvent e) {
  2. if (!armed && !dragging) return;
  3. int newPos = e.getPoint().x;
  4. TableColumn c0 = getColumnModel().getColumn(0);
  5. TableColumn c1 = getColumnModel().getColumn(1);
  6. int min = Math.max(c0.getMinWidth(), getWidth() -
  7. c1.getMaxWidth());
  8. int max = Math.min(c0.getMaxWidth(), getWidth() -
  9. c1.getMinWidth());
  10. if ((newPos >= min) && (newPos <= max)) {
  11. pos = newPos;
  12. update();
  13. }
  14. }

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

  1. public static boolean skipableColumn(TableColumn tc) {
  2. return (tc.getWidth() == 0 && tc.getMinWidth() == 0 && tc.getMaxWidth() == 0);
  3. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

  1. /**
  2. * Return the maximum size of the header. The maximum width is the sum
  3. * of the maximum widths of each column (plus inter-cell spacing).
  4. */
  5. public Dimension getMaximumSize(JComponent c)
  6. {
  7. long width=0;
  8. Enumeration enumeration=header.getColumnModel().getColumns();
  9. while(enumeration.hasMoreElements())
  10. {
  11. TableColumn aColumn=(TableColumn)enumeration.nextElement();
  12. width=width+aColumn.getMaxWidth();
  13. }
  14. return createHeaderSize(width);
  15. }

代码示例来源:origin: org.netbeans.api/org-openide-explorer

  1. public void mouseDragged(MouseEvent e) {
  2. if (!armed && !dragging) {
  3. return;
  4. }
  5. int newPos = e.getPoint().x;
  6. TableColumn c0 = getColumnModel().getColumn(0);
  7. TableColumn c1 = getColumnModel().getColumn(1);
  8. int min = Math.max(c0.getMinWidth(), getWidth() - c1.getMaxWidth());
  9. int max = Math.min(c0.getMaxWidth(), getWidth() - c1.getMinWidth());
  10. if ((newPos >= min) && (newPos <= max)) {
  11. pos = newPos;
  12. update();
  13. }
  14. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

  1. public void mouseDragged(MouseEvent e) {
  2. if (!armed && !dragging) return;
  3. int newPos = e.getPoint().x;
  4. TableColumn c0 = getColumnModel().getColumn(0);
  5. TableColumn c1 = getColumnModel().getColumn(1);
  6. int min = Math.max(c0.getMinWidth(), getWidth() -
  7. c1.getMaxWidth());
  8. int max = Math.min(c0.getMaxWidth(), getWidth() -
  9. c1.getMinWidth());
  10. if ((newPos >= min) && (newPos <= max)) {
  11. pos = newPos;
  12. update();
  13. }
  14. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

  1. /**
  2. * Return the maximum size of the table. The maximum height is the
  3. * row heighttimes the number of rows.
  4. * The maximum width is the sum of the maximum widths of each column.
  5. */
  6. public Dimension getMaximumSize(JComponent c)
  7. {
  8. long width=0;
  9. Enumeration enumeration=table.getColumnModel().getColumns();
  10. while(enumeration.hasMoreElements())
  11. {
  12. TableColumn aColumn=(TableColumn)enumeration.nextElement();
  13. width=width+aColumn.getMaxWidth();
  14. }
  15. Dimension result=createTableSize(width);
  16. result.width+=c.getInsets().left+c.getInsets().right;
  17. result.height+=c.getInsets().top+c.getInsets().bottom;
  18. return result;
  19. }

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

  1. public final void setTableColumn(TableColumn aColumn) {
  2. if (tableColumn != null) {
  3. tableColumn.removePropertyChangeListener(columnListener);
  4. }
  5. if (aColumn == null && tableColumn != null) {
  6. minWidth = tableColumn.getMinWidth();
  7. maxWidth = tableColumn.getMaxWidth();
  8. if (tableColumn.getHeaderValue() instanceof String) {
  9. title = (String) tableColumn.getHeaderValue();
  10. }
  11. }
  12. tableColumn = aColumn;
  13. if (tableColumn != null) {
  14. tableColumn.addPropertyChangeListener(columnListener);
  15. }
  16. }

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

  1. private void hideColumn() {
  2. tempWidth = super.getWidth();
  3. tempMinWidth = super.getMinWidth();
  4. tempMaxWidth = super.getMaxWidth();
  5. tempResizable = super.getResizable();
  6. tempMoveable = moveable;
  7. setResizeable(false);
  8. setMoveable(false);
  9. setMinWidth(0);
  10. setWidth(0);
  11. setMaxWidth(0);
  12. }

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

  1. public void copyValues(TableColumn base) {
  2. modelIndex = base.getModelIndex();
  3. identifier = base.getIdentifier();
  4. width = base.getWidth();
  5. minWidth = base.getMinWidth();
  6. setPreferredWidth(base.getPreferredWidth());
  7. maxWidth = base.getMaxWidth();
  8. headerRenderer = base.getHeaderRenderer();
  9. headerValue = base.getHeaderValue();
  10. cellRenderer = base.getCellRenderer();
  11. cellEditor = base.getCellEditor();
  12. isResizable = base.getResizable();
  13. }
  14. }

相关文章