Example usage for javax.swing JScrollBar setUnitIncrement

List of usage examples for javax.swing JScrollBar setUnitIncrement

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The scrollbar's unit increment.")
public void setUnitIncrement(int unitIncrement) 

Source Link

Document

Sets the unitIncrement property.

Usage

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());
    JScrollBar hbar = new JScrollBar(JScrollBar.HORIZONTAL, 30, 20, 0, 300);
    JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
    hbar.setUnitIncrement(2);
    hbar.setBlockIncrement(1);//from   www  .java 2  s  . c o  m

    hbar.addAdjustmentListener(new MyAdjustmentListener());
    vbar.addAdjustmentListener(new MyAdjustmentListener());

    add(hbar, BorderLayout.SOUTH);
    add(vbar, BorderLayout.EAST);
    add(label, BorderLayout.CENTER);
}

From source file:MainClass.java

public MainClass() {
    super(true);/*  w ww  . ja v  a2  s  . co  m*/

    setLayout(new BorderLayout());

    JScrollBar hbar = new JScrollBar(JScrollBar.HORIZONTAL, 30, 20, 0, 300);
    JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);

    hbar.setUnitIncrement(2);
    hbar.setBlockIncrement(1);

    hbar.addAdjustmentListener(new MyAdjustmentListener());
    vbar.addAdjustmentListener(new MyAdjustmentListener());

    add(hbar, BorderLayout.SOUTH);
    add(vbar, BorderLayout.EAST);
    add(label, BorderLayout.CENTER);
}

From source file:SwingScrollBarExample.java

public SwingScrollBarExample() {
    super(true);/* w w  w . j  av  a  2s.c om*/
    label = new JLabel();
    setLayout(new BorderLayout());

    JScrollBar hbar = new JScrollBar(JScrollBar.HORIZONTAL, 30, 20, 0, 300);
    JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);

    hbar.setUnitIncrement(2);
    hbar.setBlockIncrement(1);

    hbar.addAdjustmentListener(new MyAdjustmentListener());
    vbar.addAdjustmentListener(new MyAdjustmentListener());

    add(hbar, BorderLayout.SOUTH);
    add(vbar, BorderLayout.EAST);
    add(label, BorderLayout.CENTER);
}

From source file:com.polivoto.vistas.Charts.java

private void crearTabla(Pregunta pregunta) {
    JScrollPane scrollPanel = new JScrollPane();
    JPanel panel = new JPanel(new GridLayout(0, 1));

    if (pregunta.obtenerCantidadDePerfiles() > 1) {
        for (int i = 0; i < pregunta.obtenerCantidadDePerfiles(); i++) {
            JPanel p = hacerTabla(pregunta,
                    ((ResultadoPorPerfil) pregunta.obtenerResultadoPorPerfil(i)).getOpciones(),
                    ((ResultadoPorPerfil) pregunta.obtenerResultadoPorPerfil(i)).getPerfil());
            panel.add(p);/*from   w  ww  . ja  v a 2s .co m*/
        }
    }
    JPanel p = hacerTabla(pregunta, pregunta.obtenerOpciones(), "Todos");
    panel.add(p);

    scrollPanel.setViewportView(panel);
    scrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    JScrollBar vertical = scrollPanel.getVerticalScrollBar();
    vertical.setValue(0);
    vertical.setUnitIncrement(30);
    panelGrafica.add(scrollPanel, BorderLayout.CENTER);
    panel.repaint();
    panel.revalidate();
    panelGrafica.repaint();
    panelGrafica.revalidate();
}

From source file:com.nbt.TreeFrame.java

private void initComponents() {
    setTitle(TITLE);/* w w w. j a v  a2s .  c  o  m*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JMenuBar menuBar = createMenuBar();
    setJMenuBar(menuBar);
    JToolBar toolBar = createToolBar();

    contentPane = new JPanel();
    setContentPane(contentPane);

    JPanel browsePanel = new JPanel();
    Border border = new TitledBorder(null, "Location");
    browsePanel.setBorder(border);

    textFile = new JTextField();
    textFile.setEditable(false);
    btnBrowse = new JButton("Browse");
    btnBrowse.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            browseAction.actionPerformed(e);
        }

    });
    scrollPane = new JScrollPane();
    JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar();
    int unitIncrement = 200;
    verticalScrollBar.setUnitIncrement(unitIncrement);

    GroupLayout gl_contentPane = new GroupLayout(contentPane);
    gl_contentPane
            .setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                    .addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup().addContainerGap()
                            .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                                    .addComponent(browsePanel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
                                    .addComponent(scrollPane, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE))
                            .addContainerGap())
                    .addComponent(toolBar, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE,
                            Short.MAX_VALUE));
    gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_contentPane.createSequentialGroup()
                    .addComponent(toolBar, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(browsePanel)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(scrollPane,
                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));

    GroupLayout gl_browsePanel = new GroupLayout(browsePanel);
    gl_browsePanel
            .setHorizontalGroup(gl_browsePanel.createParallelGroup(Alignment.LEADING)
                    .addGroup(Alignment.TRAILING, gl_browsePanel.createSequentialGroup().addContainerGap()
                            .addComponent(textFile, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE,
                                    Short.MAX_VALUE)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnBrowse)
                            .addContainerGap()));
    gl_browsePanel.setVerticalGroup(gl_browsePanel.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_browsePanel.createSequentialGroup()
                    // .addContainerGap()
                    .addGroup(gl_browsePanel
                            .createParallelGroup(Alignment.BASELINE).addComponent(textFile,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
                            .addComponent(btnBrowse))
                    .addContainerGap()));
    browsePanel.setLayout(gl_browsePanel);
    contentPane.setLayout(gl_contentPane);

    int width = 440, height = 400;
    setMinimumSize(new Dimension(width, height));

    pack();
}