Search in sources :

Example 11 with JScrollBar

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

the class LWTextAreaPeer method getMinimumSize.

@Override
public Dimension getMinimumSize(final int rows, final int columns) {
    final Dimension size = super.getMinimumSize(rows, columns);
    synchronized (getDelegateLock()) {
        // JScrollPane insets
        final Insets pi = getDelegate().getInsets();
        size.width += pi.left + pi.right;
        size.height += pi.top + pi.bottom;
        // Take scrollbars into account.
        final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
        if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
            final JScrollBar vbar = getDelegate().getVerticalScrollBar();
            size.width += vbar != null ? vbar.getMinimumSize().width : 0;
        }
        final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
        if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
            final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
            size.height += hbar != null ? hbar.getMinimumSize().height : 0;
        }
    }
    return size;
}
Also used : Insets(java.awt.Insets) Dimension(java.awt.Dimension) Point(java.awt.Point) JScrollBar(javax.swing.JScrollBar)

Example 12 with JScrollBar

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

the class LWScrollBarPeer method initializeImpl.

@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(), target.getMinimum(), target.getMaximum());
    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL ? Adjustable.HORIZONTAL : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
Also used : Scrollbar(java.awt.Scrollbar) JScrollBar(javax.swing.JScrollBar)

Example 13 with JScrollBar

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

the class FileHistoryAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    JFrame frame = new JmriJFrame() {
    };
    // JmriJFrame to ensure fits on screen
    JTextArea pane = new JTextArea();
    // add a little space at top
    pane.append("\n");
    pane.setEditable(false);
    JScrollPane scroll = new JScrollPane(pane);
    frame.getContentPane().add(scroll);
    FileHistory r = InstanceManager.getNullableDefault(FileHistory.class);
    if (r == null) {
        pane.append("<No History Found>\n");
    } else {
        pane.append(r.toString());
    }
    // add a little space at bottom
    pane.append("\n");
    frame.pack();
    // start scrolled to top
    JScrollBar b = scroll.getVerticalScrollBar();
    b.setValue(b.getMaximum());
    // show
    frame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) JmriJFrame(jmri.util.JmriJFrame) FileHistory(jmri.jmrit.revhistory.FileHistory) JScrollBar(javax.swing.JScrollBar)

Example 14 with JScrollBar

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

the class ReportContextAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent ev) {
    // JmriJFrame to ensure fits on screen
    final JFrame frame = new JmriJFrame(Bundle.getMessage("TitleContext"));
    final Clipboard clipboard = frame.getToolkit().getSystemClipboard();
    pane = new JTextArea();
    // add a little space at top
    pane.append("\n");
    pane.setEditable(false);
    pane.setLineWrap(true);
    pane.setWrapStyleWord(true);
    pane.setColumns(120);
    JScrollPane scroll = new JScrollPane(pane);
    frame.add(scroll, BorderLayout.CENTER);
    ReportContext r = new ReportContext();
    addString(r.getReport(true));
    // add a little space at bottom
    pane.append("\n");
    // Add button to allow copy to clipboard
    JPanel p = new JPanel();
    JButton copy = new JButton(Bundle.getMessage("ButtonCopyClip"));
    copy.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            StringSelection text = new StringSelection(pane.getText());
            clipboard.setContents(text, text);
        }
    });
    p.add(copy);
    JButton close = new JButton(Bundle.getMessage("ButtonClose"));
    close.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            frame.setVisible(false);
            frame.dispose();
        }
    });
    p.add(close);
    frame.add(p, BorderLayout.SOUTH);
    frame.pack();
    // start scrolled to top
    pane.setCaretPosition(0);
    JScrollBar b = scroll.getVerticalScrollBar();
    b.setValue(b.getMaximum());
    // show
    frame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) StringSelection(java.awt.datatransfer.StringSelection) JScrollBar(javax.swing.JScrollBar) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) JmriJFrame(jmri.util.JmriJFrame) Clipboard(java.awt.datatransfer.Clipboard) ReportContext(jmri.jmrit.mailreport.ReportContext)

Example 15 with JScrollBar

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

the class Test7163696 method run.

public void run() {
    if (this.bar == null) {
        this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
        this.bar.setPreferredSize(new Dimension(400, 20));
        JFrame frame = new JFrame();
        frame.add(this.bar);
        frame.pack();
        frame.setVisible(true);
    } else if (40 != this.bar.getValue()) {
        System.out.println("name = " + UIManager.getLookAndFeel().getName());
        System.out.println("value = " + this.bar.getValue());
    } else {
        SwingUtilities.getWindowAncestor(this.bar).dispose();
        this.bar = null;
    }
}
Also used : JFrame(javax.swing.JFrame) Dimension(java.awt.Dimension) 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