List of usage examples for javax.swing JScrollPane getHorizontalScrollBar
@Transient
public JScrollBar getHorizontalScrollBar()
From source file:org.openmicroscopy.shoola.agents.dataBrowser.browser.BrowserModel.java
/** * Implemented as specified by the {@link Browser} interface. * @see Browser#scrollToNode(ImageDisplay) *//* w w w . j a v a 2s .c om*/ public void scrollToNode(ImageDisplay node) { if (node == null) return; JScrollPane pane = rootDisplay.getDeskDecorator(); Rectangle bounds = node.getBounds(); Rectangle viewRect = pane.getViewport().getViewRect(); if (viewRect.contains(bounds)) return; JScrollBar hBar = pane.getHorizontalScrollBar(); if (hBar.isVisible()) { int x = bounds.x; int max = hBar.getMaximum(); if (x > max) x = max; hBar.setValue(x); } JScrollBar vBar = pane.getVerticalScrollBar(); if (vBar.isVisible()) { int y = bounds.y; int max = vBar.getMaximum(); if (y > max) y = max; vBar.setValue(y); } }
From source file:storybook.toolkit.swing.SwingUtil.java
public static void setUnitIncrement(JScrollPane scroller) { scroller.getVerticalScrollBar().setUnitIncrement(20); scroller.getHorizontalScrollBar().setUnitIncrement(20); }
From source file:ua.com.fielden.platform.example.swing.egi.EgiExample.java
private void addTotalsFooterTo(final EntityGridInspector egi, final JPanel topPanel) { // final JPanel panel = new JPanel(new MigLayout("insets 0", "[]", "[]0[]push[]")); // panel.add(egi.getTableHeader(), "grow, wrap"); // panel.add(egi, "grow, wrap"); final JScrollPane scrollPane = new JScrollPane(egi); topPanel.add(scrollPane, "grow, wrap"); final JPanel footer = new JPanel(new MigLayout("nogrid, insets 0")); // footer.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); final List<JComponent> totalsComponents = new ArrayList<JComponent>(); for (int i = 0; i < egi.getColumnCount(); i++) { final TableColumn column = egi.getColumnModel().getColumn(i); final JComponent totalsComponent = i % 2 == 0 ? new JTextField("totals " + i) : new JLabel(); totalsComponent.setPreferredSize(new Dimension(column.getPreferredWidth(), 30)); footer.add(totalsComponent, "grow"); totalsComponents.add(totalsComponent); }//from w w w . jav a 2 s .co m final JScrollPane footerPane = new JScrollPane(footer, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); topPanel.add(footerPane, "grow, wrap, h 40::"); topPanel.add(scrollPane.getHorizontalScrollBar(), "grow, wrap"); scrollPane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(final AdjustmentEvent e) { footerPane.getViewport().setViewPosition(new Point(e.getValue(), 0)); } }); egi.getColumnModel().addColumnModelListener(new TableColumnModelListener() { @Override public void columnAdded(final TableColumnModelEvent e) { } @Override public void columnMarginChanged(final ChangeEvent e) { final TableColumn column = egi.getTableHeader().getResizingColumn(); if (column != null) { final JComponent totalsComponent = totalsComponents .get(egi.convertColumnIndexToView(column.getModelIndex())); totalsComponent.setPreferredSize(new Dimension(column.getWidth(), totalsComponent.getHeight())); footer.revalidate(); } } @Override public void columnMoved(final TableColumnModelEvent e) { final JComponent fromComponent = totalsComponents.get(e.getFromIndex()); totalsComponents.set(e.getFromIndex(), totalsComponents.get(e.getToIndex())); totalsComponents.set(e.getToIndex(), fromComponent); footer.removeAll(); for (int i = 0; i < egi.getColumnCount(); i++) { footer.add(totalsComponents.get(i), "grow, gap 0 0 0 0"); } footer.revalidate(); } @Override public void columnRemoved(final TableColumnModelEvent e) { } @Override public void columnSelectionChanged(final ListSelectionEvent e) { } }); // // return panel; }