Search in sources :

Example 21 with JScrollBar

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());
}
Also used : JScrollPane(javax.swing.JScrollPane) LoggerRepository(org.apache.log4j.spi.LoggerRepository) JTextArea(javax.swing.JTextArea) ArrayList(java.util.ArrayList) Logger(org.apache.log4j.Logger) JScrollBar(javax.swing.JScrollBar)

Example 22 with JScrollBar

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());
}
Also used : JScrollBar(javax.swing.JScrollBar)

Example 23 with JScrollBar

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());
}
Also used : JScrollBar(javax.swing.JScrollBar)

Example 24 with JScrollBar

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;
}
Also used : JScrollPane(javax.swing.JScrollPane) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BoxLayout(javax.swing.BoxLayout) IOException(java.io.IOException) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) BufferedReader(java.io.BufferedReader) JmriPanel(jmri.util.swing.JmriPanel) JmriPanel(jmri.util.swing.JmriPanel)

Example 25 with JScrollBar

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");
    }
}
Also used : JViewport(javax.swing.JViewport) 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