/** * Scrolls the GUI panel to the bottom to show latest result * whenever a new image added to the GUI panel */ private static void scrollToBottomAndRepaint(ImageClassificationPanel panel) { Component[] components = panel.getComponents(); for (Component component : components) { if (component instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) component; JList list = (JList) scrollPane.getViewport().getView(); int size = list.getModel().getSize(); list.setSelectedIndex(Math.max(size - 2, list.getLastVisibleIndex())); JScrollBar vertical = scrollPane.getVerticalScrollBar(); vertical.setValue(vertical.getMaximum()); panel.repaint(scrollPane.getBounds()); } } }
@Override public void layoutContainer(Container parent) { JScrollPane scrollPane = (JScrollPane)parent; Rectangle availR = scrollPane.getBounds(); availR.x = availR.y = 0; Insets insets = parent.getInsets(); availR.x = insets.left; availR.y = insets.top; availR.width -= insets.left + insets.right; availR.height -= insets.top + insets.bottom; Rectangle vsbR = new Rectangle(); vsbR.width = 5; vsbR.height = availR.height; vsbR.x = availR.x + availR.width - vsbR.width; vsbR.y = availR.y; if(viewport != null) { viewport.setBounds(availR); } if(vsb != null) { vsb.setVisible(true); vsb.setBounds(vsbR); } } });
protected Point getInnerInsetPt(JScrollPane testComp, Point aPt) { Point res = new Point(0, 0); if (testComp != null && aPt != null) { int autoscrollZone = Math.round(INSET_ZONE * autoscrollingVelocityFactor); Rectangle viewRect = autoscrollingPane.getBounds(); JScrollBar vSb = autoscrollingPane.getVerticalScrollBar(); if (vSb != null && vSb.isVisible()) { viewRect.width -= vSb.getWidth(); } JScrollBar hSb = autoscrollingPane.getHorizontalScrollBar(); if (hSb != null && hSb.isVisible()) { viewRect.height -= hSb.getHeight(); } if (aPt.x > 0 && aPt.x < INSET_ZONE) { res.x = -autoscrollZone; } else if (aPt.x > viewRect.width - INSET_ZONE && aPt.x < viewRect.width) { res.x = autoscrollZone; } if (aPt.y > 0 && aPt.y < INSET_ZONE) { res.y = -autoscrollZone; } else if (aPt.y > viewRect.height - INSET_ZONE && aPt.y < viewRect.height) { res.y = autoscrollZone; } } return res; }
protected boolean isInnerInsetPt(JScrollPane testComp, Point aPt) { if (testComp == null) { return false; } Rectangle bounds = testComp.getBounds(); bounds.x = 0; bounds.y = 0; JScrollBar vSb = testComp.getVerticalScrollBar(); if (vSb != null && vSb.isVisible()) { bounds.width -= vSb.getWidth(); } JScrollBar hSb = testComp.getHorizontalScrollBar(); if (hSb != null && hSb.isVisible()) { bounds.height -= hSb.getHeight(); } return ((aPt.x > 0 && aPt.x < INSET_ZONE) || (aPt.x > bounds.width - INSET_ZONE && aPt.x < bounds.width) || (aPt.y > 0 && aPt.y < INSET_ZONE) || (aPt.y > bounds.height - INSET_ZONE && aPt.y < bounds.height)); }
/** * Removes the overlay. */ public void endOverlay() { view.getComponent().requestFocus(); if (editScrollContainer != null) { editScrollContainer.setVisible(false); view.getComponent().remove(editScrollContainer); Rectangle bounds = editScrollContainer.getBounds(); view.getComponent().repaint(bounds.x, bounds.y, bounds.width, bounds.height); } if (editedFigure != null) { editedFigure.removeFigureListener(figureHandler); editedFigure = null; } } }
hsbPolicy = scrollPane.getHorizontalScrollBarPolicy(); Rectangle availR = scrollPane.getBounds(); availR.x = availR.y = 0;
hsbPolicy = scrollPane.getHorizontalScrollBarPolicy(); Rectangle availR = scrollPane.getBounds(); availR.x = availR.y = 0;
hsbPolicy = scrollPane.getHorizontalScrollBarPolicy(); final Rectangle availR = scrollPane.getBounds(); final Insets insets = parent.getInsets(); availR.x = insets.left;
hsbPolicy = scrollPane.getHorizontalScrollBarPolicy(); Rectangle availR = scrollPane.getBounds(); Insets insets = parent.getInsets(); availR.x = insets.left;
hsbPolicy = scrollPane.getHorizontalScrollBarPolicy(); Rectangle availR = scrollPane.getBounds(); availR.x = availR.y = 0;
hsbPolicy = scrollPane.getHorizontalScrollBarPolicy(); Rectangle availR = scrollPane.getBounds(); availR.x = availR.y = 0;
hsbPolicy = scrollPane.getHorizontalScrollBarPolicy(); Rectangle availR = scrollPane.getBounds(); availR.x = availR.y = 0;