@Override public void layoutContainer(Container target) { super.layoutContainer(target); int width = LightScrollPane.this.getWidth(); int height = LightScrollPane.this.getHeight(); LightScrollPane.this.scrollPane.setBounds(0, 0, width, height); int scrollBarSize = THUMB_SIZE; int cornerOffset = LightScrollPane.this.verticalScrollBar.isVisible() && LightScrollPane.this.horizontalScrollBar.isVisible() ? scrollBarSize : 0; if (LightScrollPane.this.verticalScrollBar.isVisible()) { LightScrollPane.this.verticalScrollBar.setBounds( LightScrollPane.this.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT ? 0 : width - scrollBarSize, 0, scrollBarSize, height - cornerOffset ); } if (LightScrollPane.this.horizontalScrollBar.isVisible()) { LightScrollPane.this.horizontalScrollBar.setBounds( 0, height - scrollBarSize, width - cornerOffset, scrollBarSize ); } } });
public boolean fitsVisibleArea() { return !infoAreaScrollPane.getVerticalScrollBar().isVisible(); }
public boolean fitsVisibleArea() { return !tableScroll.getVerticalScrollBar().isVisible(); }
protected ImageIcon getAutoScrollIcon() { ImageIcon icon; if (scrollPane.getHorizontalScrollBar().isVisible()) { if (scrollPane.getVerticalScrollBar().isVisible()) { icon = HV_IMAGE_ICON; } else { icon = H_IMAGE_ICON; } } else { if (scrollPane.getVerticalScrollBar().isVisible()) { icon = V_IMAGE_ICON; } else { icon = HV_IMAGE_ICON; } } return icon; }
/** * Returns {@code false} for visible translucent scroll bars, or {@code true} otherwise. * It is needed to repaint translucent scroll bars on viewport repainting. */ private static boolean isOptimizedDrawingEnabledFor(JScrollBar bar) { return bar == null || bar.isOpaque() || !bar.isVisible(); }
private boolean shouldExtendViewportUnderScrollbar(@Nullable JScrollBar scrollbar) { if (scrollbar == null || !scrollbar.isVisible()) return false; return isOverlaidScrollbar(scrollbar); }
private void propagateTableColumns() { // Set last column of tableTotal to match size of scrollbar. JScrollBar scrollbar = list.scrollFiles.getVerticalScrollBar(); int sbWidth = scrollbar == null || !scrollbar.isVisible() ? 0 : scrollbar.getWidth(); list.tableTotal.getColumnModel().getColumn(TotalsTableColumn.MARGIN.index).setPreferredWidth(sbWidth); // Propagate column sizes to totals table for (int i = 0; i < list.tableFiles.getColumnCount(); i++) { TableColumn srcCol = list.tableFiles.getColumnModel().getColumn(i); TableColumn trgCol = list.tableTotal.getColumnModel().getColumn(i); trgCol.setPreferredWidth(srcCol.getWidth()); } }
public void run() { double mainWidth = main.getSize().getWidth(); double optionsWidth = options.getPreferredSize().getWidth(); // consider scrollbar width if visible double scrollWidth = options.getVerticalScrollBar().isVisible() ? options.getVerticalScrollBar().getWidth() : 0; double loc = (mainWidth - optionsWidth - scrollWidth) / mainWidth; if(loc>=0 && loc<=1) // Might be NaN, if plugin is switched before panel is shown. main.setDividerLocation(loc); } });
public void run() { double mainWidth = main.getWidth(); double optionsWidth = options.getPreferredSize().getWidth(); // consider scrollbar width if visible double scrollWidth = options.getVerticalScrollBar().isVisible() ? options.getVerticalScrollBar().getWidth() : 0; double loc = (mainWidth - optionsWidth - scrollWidth) / mainWidth; if(loc>=0 && loc<=1) // Might be NaN, if plugin is switched before panel is shown. main.setDividerLocation(loc); } });
public void run() { double mainWidth = main.getWidth(); double optionsWidth = options.getPreferredSize().getWidth(); // consider scrollbar width if visible double scrollWidth = options.getVerticalScrollBar().isVisible() ? options.getVerticalScrollBar().getWidth() : 0; double loc = (mainWidth - optionsWidth - scrollWidth) / mainWidth; if(loc>=0 && loc<=1) // Might be NaN, if plugin is switched before panel is shown. main.setDividerLocation(loc); } });
/** * Returns the alignment of the specified scroll bar * if and only if the specified scroll bar * is located over the main viewport. * * @param bar the scroll bar to process * @return the scroll bar alignment or {@code null} */ private static Alignment getAlignment(JScrollBar bar) { if (bar != null && bar.isVisible() && !bar.isOpaque()) { return (Alignment) UIUtil.getClientProperty(bar, Alignment.class); } return null; }
public void run() { try { if (vBar.isVisible()) vBar.setValue(vBar.getMaximum() - vBar.getModel().getExtent()); console.repaint(); } catch (Exception exc) { JOptionPane.showMessageDialog(null, "Error #0005\n" + "Failed to set the JScrollBar to Max Value!\n" + exc.getMessage(), "Error Caught", JOptionPane.ERROR_MESSAGE); } } });
/** * Compute the best height to show all the items of the JTree * plus the decoration height. * @return Height in pixels */ public Dimension getMinimalComponentDimension() { Dimension panel = getPreferredSize(); Dimension treeDim = tree.getPreferredSize(); // Get the vertical scrollbar width JScrollBar scrollBar = scrollPane.getVerticalScrollBar(); if(scrollBar!=null && scrollBar.isVisible()) { return new Dimension(panel.width+scrollBar.getWidth(),treeDim.height+getMinimumSize().height); } else { return new Dimension(panel.width,treeDim.height+getMinimumSize().height); } } }
@Override public void run() { try { sleep(80); // Time out for a tenth of a second if (vBar.isVisible()) vBar.setValue(vBar.getMaximum() - vBar.getModel().getExtent()); console.repaint(); } catch (Exception exc) { JOptionPane.showMessageDialog(null, "Error #0005\n" + "Failed to set the JScrollBar to Max Value!\n" + exc.getMessage(), "Error Caught", JOptionPane.ERROR_MESSAGE); } } }.start();
public static boolean isValidCellBoundary(Component aTarget) { JScrollPane scroll = getFirstScrollPane(aTarget); if (scroll != null && (scroll.getHorizontalScrollBar() == null || !scroll.getHorizontalScrollBar().isVisible())) { Point rightOnScroll = SwingUtilities.convertPoint(aTarget, new Point(aTarget.getWidth(), 1), scroll); int scrollRightBoundary = (scroll.getWidth() - (scroll.getInsets() != null ? scroll.getInsets().right : 0)); return (scrollRightBoundary - rightOnScroll.x) > MultiLevelHeader.PICK_MARGIN_SIZE; } return true; } }
public void mouseWheelMoved(MouseWheelEvent e) { final JScrollBar sb = (vertical.isVisible()) ? vertical : horizontal; // vertical is preferred if(e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { final int amt = e.getUnitsToScroll() * sb.getUnitIncrement(); sb.setValue(sb.getValue() + amt); } else if(e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL){ final int amt = e.getWheelRotation() * sb.getBlockIncrement(); sb.setValue(sb.getValue() + amt); } }// mouseWheelMoved() }// inner class WheelListener
public void mouseWheelMoved(MouseWheelEvent e) { final JScrollBar sb = (vertical.isVisible()) ? vertical : horizontal; // vertical is preferred if(e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { final int amt = e.getUnitsToScroll() * sb.getUnitIncrement(); sb.setValue(sb.getValue() + amt); } else if(e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL){ final int amt = e.getWheelRotation() * sb.getBlockIncrement(); sb.setValue(sb.getValue() + amt); } }// mouseWheelMoved() }// inner class WheelListener
public void mouseWheelMoved(MouseWheelEvent e) { final JScrollBar sb = (vertical.isVisible()) ? vertical : horizontal; // vertical is preferred if(e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { final int amt = e.getUnitsToScroll() * sb.getUnitIncrement(); sb.setValue(sb.getValue() + amt); } else if(e.getScrollType() == MouseWheelEvent.WHEEL_BLOCK_SCROLL){ final int amt = e.getWheelRotation() * sb.getBlockIncrement(); sb.setValue(sb.getValue() + amt); } }// mouseWheelMoved() }// inner class WheelListener