Search in sources :

Example 6 with JScrollBar

use of javax.swing.JScrollBar in project jdk8u_jdk by JetBrains.

the class XTextAreaPeer method insert.

/**
     * insert the text "txt on position "pos" in the array lines
     * @see java.awt.peer.TextAreaPeer
     */
@Override
public void insert(String txt, int p) {
    if (jtext != null) {
        boolean doScroll = (p >= jtext.getDocument().getLength() && jtext.getDocument().getLength() != 0);
        jtext.insert(txt, p);
        textPane.validate();
        if (doScroll) {
            JScrollBar bar = textPane.getVerticalScrollBar();
            if (bar != null) {
                bar.setValue(bar.getMaximum() - bar.getVisibleAmount());
            }
        }
    }
}
Also used : JScrollBar(javax.swing.JScrollBar)

Example 7 with JScrollBar

use of javax.swing.JScrollBar in project jabref by JabRef.

the class MainTable method scrollTo.

public void scrollTo(int y) {
    JScrollBar scb = pane.getVerticalScrollBar();
    scb.setValue(y * scb.getUnitIncrement(1));
}
Also used : JScrollBar(javax.swing.JScrollBar)

Example 8 with JScrollBar

use of javax.swing.JScrollBar in project jabref by JabRef.

the class MainTable method ensureVisible.

public void ensureVisible(int row) {
    JScrollBar vert = pane.getVerticalScrollBar();
    int y = row * getRowHeight();
    if ((y < vert.getValue()) || ((y >= (vert.getValue() + vert.getVisibleAmount())) && (model.getSearchState() != MainTableDataModel.DisplayOption.FLOAT))) {
        scrollToCenter(row, 1);
    }
}
Also used : Point(java.awt.Point) JScrollBar(javax.swing.JScrollBar)

Example 9 with JScrollBar

use of javax.swing.JScrollBar in project JMRI by JMRI.

the class Editor method setScrollbarScale.

private void setScrollbarScale(double ratio) {
    //resize the panel to reflect scaling
    Dimension dim = _targetPanel.getSize();
    int tpWidth = (int) ((dim.width) * ratio);
    int tpHeight = (int) ((dim.height) * ratio);
    _targetPanel.setSize(tpWidth, tpHeight);
    log.debug("setScrollbarScale: ratio= {}, tpWidth= {}, tpHeight= {}", ratio, tpWidth, tpHeight);
    // compute new scroll bar positions to keep upper left same
    JScrollBar horScroll = _panelScrollPane.getHorizontalScrollBar();
    JScrollBar vertScroll = _panelScrollPane.getVerticalScrollBar();
    int hScroll = (int) (horScroll.getValue() * ratio);
    int vScroll = (int) (vertScroll.getValue() * ratio);
    // set scrollbars maximum range (otherwise setValue may fail);
    horScroll.setMaximum((int) ((horScroll.getMaximum()) * ratio));
    vertScroll.setMaximum((int) ((vertScroll.getMaximum()) * ratio));
    // set scroll bar positions
    horScroll.setValue(hScroll);
    vertScroll.setValue(vScroll);
}
Also used : Dimension(java.awt.Dimension) Point(java.awt.Point) JScrollBar(javax.swing.JScrollBar)

Example 10 with JScrollBar

use of javax.swing.JScrollBar in project jdk8u_jdk by JetBrains.

the class LWTextAreaPeer method insert.

@Override
public void insert(final String text, final int pos) {
    final ScrollableJTextArea pane = getDelegate();
    synchronized (getDelegateLock()) {
        final JTextArea area = pane.getView();
        final boolean doScroll = pos >= area.getDocument().getLength() && area.getDocument().getLength() != 0;
        area.insert(text, pos);
        revalidate();
        if (doScroll) {
            final JScrollBar vbar = pane.getVerticalScrollBar();
            if (vbar != null) {
                vbar.setValue(vbar.getMaximum() - vbar.getVisibleAmount());
            }
        }
    }
    repaintPeer();
}
Also used : JTextArea(javax.swing.JTextArea) JScrollBar(javax.swing.JScrollBar)

Aggregations

JScrollBar (javax.swing.JScrollBar)26 JScrollPane (javax.swing.JScrollPane)6 Dimension (java.awt.Dimension)5 JTextArea (javax.swing.JTextArea)5 Point (java.awt.Point)4 JFrame (javax.swing.JFrame)3 JLabel (javax.swing.JLabel)3 JViewport (javax.swing.JViewport)3 GridBagConstraints (java.awt.GridBagConstraints)2 JButton (javax.swing.JButton)2 JPanel (javax.swing.JPanel)2 JPopupMenu (javax.swing.JPopupMenu)2 JTabbedPane (javax.swing.JTabbedPane)2 JTextPane (javax.swing.JTextPane)2 JmriJFrame (jmri.util.JmriJFrame)2 GCResourceGroup (com.tagtraum.perf.gcviewer.view.model.GCResourceGroup)1 Component (java.awt.Component)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 Scrollbar (java.awt.Scrollbar)1