use of javax.swing.JScrollBar in project JMRI by JMRI.
the class Log4JTreePane method initComponents.
/**
* 2nd stage of initialization, invoked after the constructor is complete.
*/
@SuppressWarnings("unchecked")
@Override
public void initComponents() throws Exception {
LoggerRepository repo = Logger.getRootLogger().getLoggerRepository();
List<String> list = new ArrayList<String>();
for (java.util.Enumeration<Logger> e = repo.getCurrentLoggers(); e.hasMoreElements(); ) {
Logger l = e.nextElement();
list.add(l.getName() + " - " + (l.getLevel() != null ? "[" + l.getLevel().toString() + "]" : "{" + Logger.getRootLogger().getLevel().toString() + "}"));
}
java.util.Collections.sort(list);
StringBuilder result = new StringBuilder();
for (String s : list) {
result.append(s).append("\n");
}
JTextArea text = new JTextArea();
text.setText(result.toString());
JScrollPane scroll = new JScrollPane(text);
add(scroll);
// start scrolled to top
text.setCaretPosition(0);
JScrollBar b = scroll.getVerticalScrollBar();
b.setValue(b.getMaximum());
}
use of javax.swing.JScrollBar in project JMRI by JMRI.
the class WarrantFrame method scrollCommandTable.
private void scrollCommandTable(int row) {
JScrollBar bar = _throttlePane.getVerticalScrollBar();
bar.setValue(row * _rowHeight);
// bar.setValue(bar.getMaximum());
}
use of javax.swing.JScrollBar in project JMRI by JMRI.
the class WarrantTableFrame method scrollTable.
protected void scrollTable() {
JScrollBar bar = _tablePane.getVerticalScrollBar();
bar.setValue(bar.getMaximum());
}
use of javax.swing.JScrollBar in project JMRI by JMRI.
the class LicenseAction method makePanel.
@Override
public jmri.util.swing.JmriPanel makePanel() {
jmri.util.swing.JmriPanel p = new JmriPanel();
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
JScrollPane jScrollPane = new JScrollPane();
JTextPane textPane = new JTextPane();
// get the file
// NOI18N
InputStream is = FileUtil.findInputStream("resources/COPYING", FileUtil.Location.INSTALLED);
String t;
try (// file stored as ASCII // NOI18N
InputStreamReader isr = new InputStreamReader(is, "US-ASCII");
BufferedReader r = new BufferedReader(isr)) {
StringBuilder buf = new StringBuilder();
while (r.ready()) {
buf.append(r.readLine());
buf.append("\n");
}
t = buf.toString();
} catch (IOException ex) {
t = "JMRI is distributed under a license. For license information, see the JMRI website http://jmri.org";
}
textPane.setText(t);
// set up display
textPane.setEditable(false);
jScrollPane.getViewport().add(textPane);
p.add(jScrollPane);
// start scrolled to top
JScrollBar b = jScrollPane.getVerticalScrollBar();
b.setValue(b.getMaximum());
return p;
}
use of javax.swing.JScrollBar in project jdk8u_jdk by JetBrains.
the class Test6526631 method validateThird.
public void validateThird() {
JViewport viewport = this.pane.getViewport();
JScrollBar scroller = this.pane.getHorizontalScrollBar();
if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
throw new Error("unexpected component orientation");
}
int value = scroller.getValue();
if (value != 0) {
throw new Error("unexpected scroll value");
}
int extent = viewport.getExtentSize().width;
if (extent != scroller.getVisibleAmount()) {
throw new Error("unexpected visible amount");
}
int size = viewport.getViewSize().width;
if (size != scroller.getMaximum()) {
throw new Error("unexpected maximum");
}
int pos = size - extent - value;
if (pos != viewport.getViewPosition().x) {
throw new Error("unexpected position");
}
}
Aggregations