Example usage for javax.swing JScrollBar JScrollBar

List of usage examples for javax.swing JScrollBar JScrollBar

Introduction

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

Prototype

public JScrollBar(int orientation) 

Source Link

Document

Creates a scrollbar with the specified orientation and the following initial values:
 minimum = 0 maximum = 100 value = 0 extent = 10 

Usage

From source file:ScrollBarPieces.java

public static void main(String args[]) {
    JScrollBar oneJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    String title = (args.length == 0 ? "ScrollBar Sample" : args[0]);
    JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container contentPane = frame.getContentPane();
    contentPane.add(oneJScrollBar, BorderLayout.NORTH);
    frame.setSize(200, 44);//from   ww w.  ja v a 2s.c om
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JScrollBar oneJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    frame.add(oneJScrollBar, BorderLayout.NORTH);
    frame.setSize(200, 44);//from  w w w . j  a  v a  2s .  co  m
    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);// ww  w  .j a va2  s. c  o  m
    panel.add(textField);
    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:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

    frame.setSize(300, 200);//from  w ww  . j  av a 2s  .c  o m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);
    System.out.println(model.getValue());

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

    frame.setSize(300, 200);/* ww  w . j  a va2s  .  co  m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);
    model.setExtent(10);/*from   w ww. jav a 2s  .  co m*/

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);
    model.setValueIsAdjusting(true);/*from  www .  j a  v  a2s  . c om*/

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

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);/* www .ja  v a  2s  .c  o  m*/
    panel.add(textField);
    panel.add(scrollBar);

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

From source file:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);
    System.out.println(model.getMinimum());

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

    frame.setSize(300, 200);//from w  w  w .  ja v  a2s  .co m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);
    model.setRangeProperties(10, 10, 0, 20, true);

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

    frame.setSize(300, 200);/*ww  w.  j  a v a 2  s.co m*/
    frame.setVisible(true);
}