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());
}
}
}
}
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));
}
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);
}
}
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);
}
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();
}
Aggregations