1693 if (rowCount > 0 && table.getColumnCount() > 0) { 1694 Rectangle r = table.getCellRect(rowCount-1, 0, true); 1695 height = r.y + r.height; 1696 } 1697 // Width is always positive. The call to abs() is a workaround for 1698 // a bug in the 1.1.6 JIT on Windows. 1699 long tmp = Math.abs(width); 1700 if (tmp > Integer.MAX_VALUE) { 1701 tmp = Integer.MAX_VALUE; 1702 } 1703 return new Dimension((int)tmp, height); 1704 } 1705 1706 /** 1707 * Return the minimum size of the table. The minimum height is the 1708 * row height times the number of rows. 1709 * The minimum width is the sum of the minimum widths of each column. 1710 */ 1711 public Dimension getMinimumSize(JComponent c) { 1712 long width = 0; 1713 Enumeration enumeration = table.getColumnModel().getColumns(); 1714 while (enumeration.hasMoreElements()) { 1715 TableColumn aColumn = (TableColumn)enumeration.nextElement(); 1716 width = width + aColumn.getMinWidth(); 1717 } 1718 return createTableSize(width); 1719 } 1720 1721 /** 1722 * Return the preferred size of the table. The preferred height is the 1723 * row height times the number of rows. 1724 * The preferred width is the sum of the preferred widths of each column. 1725 */ 1726 public Dimension getPreferredSize(JComponent c) { 1727 long width = 0; 1728 Enumeration enumeration = table.getColumnModel().getColumns(); 1729 while (enumeration.hasMoreElements()) { 1730 TableColumn aColumn = (TableColumn)enumeration.nextElement(); 1731 width = width + aColumn.getPreferredWidth(); 1732 } 1733 return createTableSize(width); 1734 } 1735 1736 /** 1737 * Return the maximum size of the table. The maximum height is the 1738 * row heighttimes the number of rows. 1739 * The maximum width is the sum of the maximum widths of each column. 1740 */ 1741 public Dimension getMaximumSize(JComponent c) { 1742 long width = 0; 1743 Enumeration enumeration = table.getColumnModel().getColumns(); 1744 while (enumeration.hasMoreElements()) { 1745 TableColumn aColumn = (TableColumn)enumeration.nextElement(); 1746 width = width + aColumn.getMaxWidth(); 1747 } 1748 return createTableSize(width); 1749 } 1750 1751 // 1752 // Paint methods and support 1753 // 1754 1755 /** Paint a representation of the <code>table</code> instance 1756 * that was set in installUI(). 1757 */ 1758 public void paint(Graphics g, JComponent c) { 1759 Rectangle clip = g.getClipBounds(); 1760 1761 Rectangle bounds = table.getBounds(); 1762 // account for the fact that the graphics has already been translated 1763 // into the table's bounds 1764 bounds.x = bounds.y = 0; 1765 | 1693 if (rowCount > 0 && table.getColumnCount() > 0) { 1694 Rectangle r = table.getCellRect(rowCount-1, 0, true); 1695 height = r.y + r.height; 1696 } 1697 // Width is always positive. The call to abs() is a workaround for 1698 // a bug in the 1.1.6 JIT on Windows. 1699 long tmp = Math.abs(width); 1700 if (tmp > Integer.MAX_VALUE) { 1701 tmp = Integer.MAX_VALUE; 1702 } 1703 return new Dimension((int)tmp, height); 1704 } 1705 1706 /** 1707 * Return the minimum size of the table. The minimum height is the 1708 * row height times the number of rows. 1709 * The minimum width is the sum of the minimum widths of each column. 1710 */ 1711 public Dimension getMinimumSize(JComponent c) { 1712 long width = 0; 1713 Enumeration<TableColumn> enumeration = table.getColumnModel().getColumns(); 1714 while (enumeration.hasMoreElements()) { 1715 TableColumn aColumn = enumeration.nextElement(); 1716 width = width + aColumn.getMinWidth(); 1717 } 1718 return createTableSize(width); 1719 } 1720 1721 /** 1722 * Return the preferred size of the table. The preferred height is the 1723 * row height times the number of rows. 1724 * The preferred width is the sum of the preferred widths of each column. 1725 */ 1726 public Dimension getPreferredSize(JComponent c) { 1727 long width = 0; 1728 Enumeration<TableColumn> enumeration = table.getColumnModel().getColumns(); 1729 while (enumeration.hasMoreElements()) { 1730 TableColumn aColumn = enumeration.nextElement(); 1731 width = width + aColumn.getPreferredWidth(); 1732 } 1733 return createTableSize(width); 1734 } 1735 1736 /** 1737 * Return the maximum size of the table. The maximum height is the 1738 * row heighttimes the number of rows. 1739 * The maximum width is the sum of the maximum widths of each column. 1740 */ 1741 public Dimension getMaximumSize(JComponent c) { 1742 long width = 0; 1743 Enumeration<TableColumn> enumeration = table.getColumnModel().getColumns(); 1744 while (enumeration.hasMoreElements()) { 1745 TableColumn aColumn = enumeration.nextElement(); 1746 width = width + aColumn.getMaxWidth(); 1747 } 1748 return createTableSize(width); 1749 } 1750 1751 // 1752 // Paint methods and support 1753 // 1754 1755 /** Paint a representation of the <code>table</code> instance 1756 * that was set in installUI(). 1757 */ 1758 public void paint(Graphics g, JComponent c) { 1759 Rectangle clip = g.getClipBounds(); 1760 1761 Rectangle bounds = table.getBounds(); 1762 // account for the fact that the graphics has already been translated 1763 // into the table's bounds 1764 bounds.x = bounds.y = 0; 1765 |