Example usage for javax.swing JScrollBar setModel

List of usage examples for javax.swing JScrollBar setModel

Introduction

In this page you can find the example usage for javax.swing JScrollBar setModel.

Prototype

@BeanProperty(expert = true, description = "The scrollbar's BoundedRangeModel.")
public void setModel(BoundedRangeModel newModel) 

Source Link

Document

Sets the model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.

Usage

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JTextField textField = new JTextField();

    JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL);

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    BoundedRangeModel brm = textField.getHorizontalVisibility();
    scrollBar.setModel(brm);
    panel.add(textField);//from   w  w  w .jav a  2 s .  c  o  m
    panel.add(scrollBar);

    frame.add(panel, BorderLayout.NORTH);
    frame.setSize(300, 100);
    frame.setVisible(true);
}

From source file:TextSlider.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Text Slider");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JTextField textField = new JTextField();

    JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL);

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    BoundedRangeModel brm = textField.getHorizontalVisibility();
    scrollBar.setModel(brm);
    panel.add(textField);/*from   w  w w. j  av  a  2 s. c o m*/
    panel.add(scrollBar);

    final TextSlider ts = new TextSlider();
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Text: " + textField.getText());
        }
    });
    frame.add(panel, BorderLayout.NORTH);
    frame.setSize(300, 100);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {

    final JTextField textField = new JTextField();

    JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL);

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    BoundedRangeModel brm = textField.getHorizontalVisibility();
    scrollBar.setModel(brm);
    panel.add(textField);//from www. j  av  a2s .  c o m
    panel.add(scrollBar);

    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Text: " + textField.getText());
        }
    });

    JFrame frame = new JFrame("Text Slider");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.add(panel, BorderLayout.NORTH);
    frame.setSize(300, 100);
    frame.setVisible(true);
}

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java

private JScrollBar createJScrollBar() {
    JScrollBar b = new JScrollBar(JScrollBar.HORIZONTAL);
    b.setModel(new DefaultBoundedRangeModel());
    b.setEnabled(false);//from w w  w.j  a  v  a2s .  c  o m
    return b;
}