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

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

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

TableColumn.getMinWidth介绍

暂无

代码示例

代码示例来源: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 getMinWidth() {
  2. if (tableColumn != null) {
  3. return tableColumn.getMinWidth();
  4. } else {
  5. return minWidth;
  6. }
  7. }

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

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

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

  1. /**
  2. * Return the minimum size of the header. The minimum width is the sum of
  3. * the minimum widths of each column (plus inter-cell spacing).
  4. */
  5. public Dimension getMinimumSize(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.getMinWidth();
  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: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

  1. /** Return the minimum size of the header. The minimum width is the sum
  2. * of the minimum widths of each column (plus inter-cell spacing).
  3. */
  4. public Dimension getMinimumSize(JComponent c)
  5. {
  6. long width=0;
  7. Enumeration enumeration=header.getColumnModel().getColumns();
  8. while(enumeration.hasMoreElements())
  9. {
  10. TableColumn aColumn=(TableColumn)enumeration.nextElement();
  11. width=width+aColumn.getMinWidth();
  12. }
  13. return createHeaderSize(width);
  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: 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: nz.ac.waikato.cms.weka/weka-stable

  1. /**
  2. * Sets the instances who's attribute names will be displayed.
  3. *
  4. * @param newInstances the new set of instances
  5. */
  6. public void setInstances(Instances newInstances) {
  7. if (m_Model == null) {
  8. m_Model = new AttributeTableModel(newInstances);
  9. m_Table.setModel(m_Model);
  10. TableColumnModel tcm = m_Table.getColumnModel();
  11. tcm.getColumn(0).setMaxWidth(60);
  12. tcm.getColumn(1).setMaxWidth(tcm.getColumn(1).getMinWidth());
  13. tcm.getColumn(2).setMinWidth(100);
  14. } else {
  15. m_Model.setInstances(newInstances);
  16. m_Table.clearSelection();
  17. }
  18. m_IncludeAll.setEnabled(true);
  19. m_RemoveAll.setEnabled(true);
  20. m_Invert.setEnabled(true);
  21. m_Pattern.setEnabled(true);
  22. m_Table.sizeColumnsToFit(2);
  23. m_Table.revalidate();
  24. m_Table.repaint();
  25. }

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

  1. /**
  2. * Sets the instances who's attribute names will be displayed.
  3. *
  4. * @param newInstances the new set of instances
  5. */
  6. public void setInstances(Instances newInstances) {
  7. if (m_Model == null) {
  8. m_Model = new AttributeTableModel(newInstances);
  9. m_Table.setModel(m_Model);
  10. TableColumnModel tcm = m_Table.getColumnModel();
  11. tcm.getColumn(0).setMaxWidth(60);
  12. tcm.getColumn(1).setMaxWidth(tcm.getColumn(1).getMinWidth());
  13. tcm.getColumn(2).setMinWidth(100);
  14. } else {
  15. m_Model.setInstances(newInstances);
  16. m_Table.clearSelection();
  17. }
  18. m_IncludeAll.setEnabled(true);
  19. m_RemoveAll.setEnabled(true);
  20. m_Invert.setEnabled(true);
  21. m_Pattern.setEnabled(true);
  22. m_Table.sizeColumnsToFit(2);
  23. m_Table.revalidate();
  24. m_Table.repaint();
  25. }

代码示例来源:origin: Waikato/meka

  1. /**
  2. * Sets the instances who's attribute names will be displayed.
  3. *
  4. * @param newInstances the new set of instances
  5. */
  6. public void setInstances(Instances newInstances) {
  7. if (m_Model == null) {
  8. m_Model = new AttributeTableModel(newInstances);
  9. m_Table.setModel(m_Model);
  10. TableColumnModel tcm = m_Table.getColumnModel();
  11. tcm.getColumn(0).setMaxWidth(60);
  12. tcm.getColumn(1).setMaxWidth(tcm.getColumn(1).getMinWidth());
  13. tcm.getColumn(2).setMinWidth(100);
  14. } else {
  15. m_Model.setInstances(newInstances);
  16. m_Table.clearSelection();
  17. }
  18. m_IncludeAll.setEnabled(true);
  19. m_RemoveAll.setEnabled(true);
  20. m_Invert.setEnabled(true);
  21. m_Pattern.setEnabled(true);
  22. m_Table.sizeColumnsToFit(2);
  23. m_Table.revalidate();
  24. m_Table.repaint();
  25. }

代码示例来源: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: 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: 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: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

  1. /**
  2. * Return the minimum size of the table. The minimum height is the
  3. * row height times the number of rows.
  4. * The minimum width is the sum of the minimum widths of each column.
  5. */
  6. public Dimension getMinimumSize(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.getMinWidth();
  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: net.sf.cuf/cuf-swing

  1. width = Math.max(width, pColumn.getMinWidth());
  2. width = Math.min(width, pColumn.getMaxWidth());

代码示例来源: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. }

相关文章