带横向滚动条的JTable

JTable aTableWithHorizontalScrollBar = new JTable() { /** * Returns false to indicate that horizontal scrollbars are required * to display the table while honoring perferred column widths. * Returns true if the table can be displayed in viewport without * horizontal scrollbars. * * @return true if an auto-resizing mode is enabled and the viewport * width is larger than the table's preferred size, * otherwise return false. * @see Scrollable#getScrollableTracksViewportWidth */ public boolean getScrollableTracksViewportWidth() { if( autoResizeMode != AUTO_RESIZE_OFF ) if( getParent() instanceof JViewport ) return (((JViewport)getParent()).getWidth() > getPreferredSize().width); return false; } };

你可能感兴趣的:(JAVA,table)