public void componentResized( ComponentEvent e) { scrollPane.doLayout(); } };
@Override public void doLayout() { if(viewport != null){ final Component view = viewport.getView(); if(view != null) view.invalidate(); } super.doLayout(); }
/** * Create comment cached image * * @param forceRefresh * @param w * @param h */ public void createCommentImage(boolean forceRefresh, int w, int h) { if (forceRefresh || scrollPane.getWidth() != w || scrollPane.getHeight() != h) { if (w > 0 && h > 0) { scrollPane.setSize(w, h); cachedCommentImage = new BufferedImage(scrollPane.getWidth(), scrollPane.getHeight(), TYPE_INT_ARGB); Graphics2D g2 = cachedCommentImage.createGraphics(); scrollPane.doLayout(); scrollPane.validate(); scrollPane.printAll(g2); g2.dispose(); } } }
scroll.setVisible(true); scroll.invalidate(); scroll.doLayout(); scroll.paintImmediately(new Rectangle(scroll.getSize()));
@Override public void doLayout() { super.doLayout(); final Insets insets = getInsets(); final int insetHeight = insets.top + insets.bottom; final Dimension prefSize = getViewport().getPreferredSize(); int height = getHeight() - insetHeight; if (getHorizontalScrollBar().isVisible()) { height -= getHorizontalScrollBar().getHeight(); } final boolean isVsbNeeded = height < prefSize.height; boolean layoutAgain = false; if (isVsbNeeded && getVerticalScrollBarPolicy() == ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER) { setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); layoutAgain = true; } else if (!isVsbNeeded && getVerticalScrollBarPolicy() == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) { setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); layoutAgain = true; } if (layoutAgain) { super.doLayout(); EventQueue.invokeLater(new Runnable() { public void run() { ((JComponent) getParent()).revalidate(); } }); } }
void installOnScrollPane(JScrollPane aScrollPane) { if (theScrollPane != null) uninstallFromScrollPane(); theScrollPane = aScrollPane; theFormerLayoutManager = theScrollPane.getLayout(); theScrollPane.setLayout(new TweakedScrollPaneLayout()); theScrollPane.firePropertyChange("layoutManager", false, true); theScrollPane.addPropertyChangeListener(COMPONENT_ORIENTATION, propertyChangeListener); theScrollPane.getViewport().addContainerListener( theViewPortViewListener); theScrollPane.setCorner(JScrollPane.LOWER_TRAILING_CORNER, theButton); Component comp = theScrollPane.getViewport().getView(); theComponent = (comp instanceof JComponent) ? (JComponent) comp : null; this.theButton.setIcon(LafWidgetRepository.getRepository() .getLafSupport().getSearchIcon( UIManager.getInt("ScrollBar.width") - 3, theScrollPane.getComponentOrientation())); theScrollPane.doLayout(); }