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() 

Source Link

Document

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

Usage

From source file:org.fhaes.FHRecorder.FireHistoryRecorder.java

private void initComponents() {

    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {

            closeAfterRunningChecks();/*from www  .  j  a va 2 s .  c o  m*/

        }

    });

    setMinimumSize(new java.awt.Dimension(950, 675));
    setResizable(true);

    getContentPane().setLayout(new MigLayout("", "[810px,grow]", "[466.00,grow][42.00]"));

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    getContentPane().add(tabbedPane, "cell 0 0,grow");

    sampleInputHolder = new JPanel();
    siteInfoHolder = new JPanel();

    sampleInputHolder.setLayout(new BorderLayout());
    siteInfoHolder.setLayout(new BorderLayout());

    tabbedPane.addTab("Data", null, sampleInputHolder, null);
    tabbedPane.addTab("Metadata", null, siteInfoHolder, null);

    summaryHolder = new JPanel();
    tabbedPane.addTab("Summary", null, summaryHolder, null);

    graphicsHolder = new JPanel();
    tabbedPane.addTab("Graphics", null, graphicsHolder, null);
    graphicsHolder.setLayout(new BorderLayout(0, 0));

    chartScrollBar = new JScrollBar();
    chartScrollBar.setMaximum(110);
    chartScrollBar.addAdjustmentListener(new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent arg0) {
            if (graphicsPanel != null) {
                graphicsPanel.updateVisibleYears(chartScrollBar.getValue());
            }
        }
    });
    chartScrollBar.setOrientation(JScrollBar.HORIZONTAL);
    graphicsHolder.add(chartScrollBar, BorderLayout.SOUTH);

    fileErrorHolder = new JPanel();
    tabbedPane.addTab("File Errors", null, fileErrorHolder, null);

    panelButtonBar = new JPanel();
    getContentPane().add(panelButtonBar, "cell 0 1,alignx right,growy");

    useLimitsCheckBox = new JCheckBox("Keep FHX2 Limitations");
    panelButtonBar.add(useLimitsCheckBox);
    useLimitsCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            siteInfo.setLimitRestriction(useLimitsCheckBox.isSelected());
        }
    });

    btnSave = new JButton("Save");
    panelButtonBar.add(btnSave);
    btnSave.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            saveMenuItemActionPerformed(e);
        }

    });

    btnClose = new JButton("Close");
    btnClose.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            closeAfterRunningChecks();
        }

    });
    panelButtonBar.add(btnClose);

    btnCancel = new JButton("Discard changes");
    panelButtonBar.add(btnCancel);
    btnCancel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            Controller.filePath = null;
            setVisible(false);

        }

    });

    pack();
}

From source file:edu.pdi2.visual.ThresholdSignature.java

private void initGUI(int cantBands) {
    try {/*from   ww  w.j a v a  2  s  .c  om*/
        {
            getContentPane().setLayout(null);
            this.setPreferredSize(new java.awt.Dimension(359, 457));
            {
                for (int i = 0; i < cantBands; ++i) {
                    scrollbars[i] = new JScrollBar();
                    getContentPane().add(scrollbars[i]);
                    scrollbars[i].setBounds(50 * i + 20, 42, 17, 71);
                    scrollbars[i].setValue(INITIAL_DEVIATION);

                    final Integer index = new Integer(i);
                    scrollbars[i].addAdjustmentListener(new AdjustmentListener() {
                        public void adjustmentValueChanged(AdjustmentEvent evt) {
                            evt.setSource(new Integer(index));
                            scrollBarAdjustmentValueChanged(evt);
                        }

                    });

                }
            }
            // {
            // jScrollBar1 = new JScrollBar();
            // getContentPane().add(jScrollBar1);
            // jScrollBar1.setBounds(20, 42, 17, 71);
            // jScrollBar1.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar1AdjustmentValueChanged(evt);
            // }
            // });
            // }
            {
                for (int i = 0; i < cantBands; ++i) {
                    bandLabels[i] = new JLabel();
                    getContentPane().add(bandLabels[i]);
                    bandLabels[i].setText("Band " + i);
                    bandLabels[i].setBounds(50 * i + 12, 23, 33, 14);

                }
            }

            // {
            // jLabel1 = new JLabel();
            // getContentPane().add(jLabel1);
            // jLabel1.setText("Band 1");
            // jLabel1.setBounds(12, 23, 33, 14);
            // }
            {
                signatureG = ChartFactory.createXYLineChart("Signature ", "Bands", "Valory", null,
                        PlotOrientation.VERTICAL, true, true, false);
                chartpanel = new ChartPanel(signatureG);
                getContentPane().add(chartpanel);
                chartpanel.setBorder(BorderFactory.createTitledBorder(""));
                chartpanel.setBounds(20, 157, 45 * cantBands + 20, 210);
            }
            // {
            // jLabel2 = new JLabel();
            // getContentPane().add(jLabel2);
            // jLabel2.setText("Band 2");
            // jLabel2.setBounds(62, 23, 33, 14);
            // }
            // {
            // jScrollBar2 = new JScrollBar();
            // getContentPane().add(jScrollBar2);
            // jScrollBar2.setBounds(70, 42, 17, 71);
            // jScrollBar2.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar2AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel3 = new JLabel();
            // getContentPane().add(jLabel3);
            // jLabel3.setText("Band 3");
            // jLabel3.setBounds(112, 23, 33, 14);
            // }
            // {
            // jScrollBar3 = new JScrollBar();
            // getContentPane().add(jScrollBar3);
            // jScrollBar3.setBounds(120, 42, 17, 71);
            // jScrollBar3.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar3AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel4 = new JLabel();
            // getContentPane().add(jLabel4);
            // jLabel4.setText("Band 4");
            // jLabel4.setBounds(162, 23, 33, 14);
            // }
            // {
            // jScrollBar4 = new JScrollBar();
            // getContentPane().add(jScrollBar4);
            // jScrollBar4.setBounds(170, 42, 17, 71);
            // jScrollBar4.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar4AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel5 = new JLabel();
            // getContentPane().add(jLabel5);
            // jLabel5.setText("Band 5");
            // jLabel5.setBounds(212, 23, 33, 14);
            // }
            // {
            // jScrollBar5 = new JScrollBar();
            // getContentPane().add(jScrollBar5);
            // jScrollBar5.setBounds(220, 42, 17, 71);
            // jScrollBar5.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar5AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel6 = new JLabel();
            // getContentPane().add(jLabel6);
            // jLabel6.setText("Band 6");
            // jLabel6.setBounds(262, 23, 33, 14);
            // }
            // {
            // jScrollBar6 = new JScrollBar();
            // getContentPane().add(jScrollBar6);
            // jScrollBar6.setBounds(270, 42, 17, 71);
            // jScrollBar6.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar6AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel7 = new JLabel();
            // getContentPane().add(jLabel7);
            // jLabel7.setText("Band 7");
            // jLabel7.setBounds(312, 23, 33, 14);
            // }
            // {
            // jScrollBar7 = new JScrollBar();
            // getContentPane().add(jScrollBar7);
            // jScrollBar7.setBounds(320, 42, 17, 71);
            // jScrollBar7.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar7AdjustmentValueChanged(evt);
            // }
            // });
            // }
            {
                for (int i = 0; i < cantBands; ++i) {
                    valueLabels[i] = new JLabel();
                    getContentPane().add(valueLabels[i]);
                    valueLabels[i].setText(String.valueOf(INITIAL_DEVIATION));
                    valueLabels[i].setBounds(50 * i + 20, 119, 33, 19);

                }
            }
            // {
            // jLabel8 = new JLabel();
            // getContentPane().add(jLabel8);
            // jLabel8.setBounds(20, 119, 33, 19);
            // jLabel8.setText("0");
            // }
            // {
            // jLabel9 = new JLabel();
            // getContentPane().add(jLabel9);
            // jLabel9.setText("0");
            // jLabel9.setBounds(70, 119, 33, 19);
            // }
            // {
            // jLabel10 = new JLabel();
            // getContentPane().add(jLabel10);
            // jLabel10.setText("0");
            // jLabel10.setBounds(120, 119, 33, 19);
            // }
            // {
            // jLabel11 = new JLabel();
            // getContentPane().add(jLabel11);
            // jLabel11.setText("0");
            // jLabel11.setBounds(170, 119, 33, 19);
            // }
            // {
            // jLabel12 = new JLabel();
            // getContentPane().add(jLabel12);
            // jLabel12.setText("0");
            // jLabel12.setBounds(220, 119, 33, 19);
            // }
            // {
            // jLabel13 = new JLabel();
            // getContentPane().add(jLabel13);
            // jLabel13.setText("0");
            // jLabel13.setBounds(270, 119, 33, 19);
            // }
            // {
            // jLabel14 = new JLabel();
            // getContentPane().add(jLabel14);
            // jLabel14.setText("0");
            // jLabel14.setBounds(320, 119, 33, 19);
            // }
            {
                btCancel = new JButton();
                getContentPane().add(btCancel);
                btCancel.setText("Cancel");
                btCancel.setBounds(51 * cantBands - 75, 379, 75, 25);
                btCancel.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent evt) {
                        btCancelMouseClicked(evt);
                    }
                });
            }
            {
                btOk = new JButton();
                getContentPane().add(btOk);
                btOk.setText("Generate");
                btOk.setBounds(51 * cantBands - 155, 379, 75, 25);
                btOk.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent evt) {
                        btOkMouseClicked(evt);
                    }
                });
            }
        }
        this.setSize(51 * cantBands + 40, 457);
        this.setResizable(false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.ku.brc.af.ui.db.ViewBasedDisplayFrame.java

@Override
public void createUI() {
    setBackground(viewBasedPanel.getBackground());

    JScrollPane scrollPane = UIHelper.createScrollPane(viewBasedPanel, true);
    scrollPane.setBorder(BorderFactory.createLineBorder(getBackground(), 8));
    contentPanel = scrollPane;//from   ww w .j a va2 s  .c  o  m

    super.createUI();

    viewBasedPanel.setOkCancelBtns(okBtn, cancelBtn);

    Integer width = (Integer) UIManager.get("ScrollBar.width");
    if (width == null) {
        width = (new JScrollBar()).getPreferredSize().width;
    }

    Dimension dim1 = getPreferredSize();
    dim1.height += width * 2;
    if (!UIHelper.isMacOS()) {
        dim1.width += width;
    }
    setSize(dim1);

    if (cancelBtn != null) {
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                cancelBtn.doClick();
            }
        });
    } else if (okBtn != null) {
        okBtn.setEnabled(true);
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                okBtn.doClick();
            }
        });
    }

    viewBasedPanel.setOkCancelBtns(okBtn, cancelBtn);

    addAL(okBtn);
    addAL(cancelBtn);
    addAL(applyBtn);
    addAL(helpBtn);
}

From source file:org.fhaes.fhrecorder.view.GraphPanel.java

/**
 * Constructor for the Graphics Panel. Sets up layout and settings of all components.
 *//*  ww w. j a v  a 2  s .c om*/
public GraphPanel() {

    data = FileController.getYearSummaryList();
    setLayout(new MigLayout("", "[grow,right]", "[fill][300px,grow,fill][][]"));

    JButton customizeButton = new JButton("Customize");
    customizeButton.setIcon(Builder.getImageIcon("configure.png"));
    customizeButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            showCustomizeWindow();
        }
    });

    zoomOutButton = new JButton("");
    zoomOutButton.setIcon(Builder.getImageIcon("zoom_out.png"));
    zoomOutButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            setZoomLevel(zoomLevel + 1);
        }

    });
    add(zoomOutButton, "flowx,cell 0 0");

    zoomInButton = new JButton("");
    zoomInButton.setIcon(Builder.getImageIcon("zoom_in.png"));
    zoomInButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            setZoomLevel(zoomLevel - 1);
        }

    });
    add(zoomInButton, "cell 0 0");
    add(customizeButton, "cell 0 0,alignx right");

    rigidArea = Box.createRigidArea(new Dimension(20, 20));
    rigidArea.setMaximumSize(new Dimension(200, 20));
    rigidArea.setMinimumSize(new Dimension(1, 20));
    add(rigidArea, "cell 0 1");
    colorPane = new ColorBarGraph(data);

    colorPane.addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {

            int notches = e.getWheelRotation();
            setZoomLevel(zoomLevel + notches);
        }

    });

    add(colorPane, "cell 0 1,growx");

    scrollBar = new JScrollBar();
    scrollBar.setMinimum(0);
    scrollBar.setMaximum(data.size());
    scrollBar.addAdjustmentListener(new AdjustmentListener() {

        @Override
        public void adjustmentValueChanged(AdjustmentEvent event) {

            setChartsFirstCategoryIndex(event.getValue());
        }
    });

    overlayPane = new GraphSummaryOverlay(data);

    overlayPane.addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {

            int notches = e.getWheelRotation();
            setZoomLevel(zoomLevel + notches);
        }

    });
    add(overlayPane, "cell 0 2,growx");
    scrollBar.setOrientation(JScrollBar.HORIZONTAL);
    add(scrollBar, "cell 0 3,growx");

    refreshCharts(false);
}

From source file:edu.ku.brc.af.ui.db.ViewBasedDisplayDialog.java

@Override
public void createUI() {
    setBackground(viewBasedPanel.getBackground());

    JScrollPane scrollPane = UIHelper.createScrollPane(viewBasedPanel, true);
    scrollPane.setBorder(BorderFactory.createLineBorder(getBackground(), 8));
    contentPanel = scrollPane;/*from w  w  w  . j  a v a 2 s .  co  m*/

    super.createUI();

    viewBasedPanel.setOkCancelBtns(okBtn, cancelBtn);

    Integer width = (Integer) UIManager.get("ScrollBar.width");
    if (width == null) {
        width = (new JScrollBar()).getPreferredSize().width;
    }

    Dimension dim1 = getPreferredSize();
    dim1.height += width * 2;
    if (!UIHelper.isMacOS()) {
        dim1.width += width;
    }
    setSize(dim1);
}

From source file:savant.view.variation.swing.VariationModule.java

/**
 * Three of our panels consist of a component next to a scroll-bar
 *//*from w w  w  .ja  v  a2s .  c o  m*/
private JPanel populatePanel(JComponent content) {
    JScrollBar scroller = new JScrollBar();
    scroller.setMinimum(1);
    scroller.addAdjustmentListener(scrollerListener);
    scrollers.add(scroller);

    JPanel container = new JPanel();
    container.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    if (content instanceof JLabel) {
        gbc.anchor = GridBagConstraints.NORTH;
        gbc.insets = MESSAGE_INSETS;
        gbc.fill = GridBagConstraints.HORIZONTAL;
    } else {
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
    }
    container.add(content, gbc);

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 0.0;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.insets = new Insets(0, 0, 0, 0);
    container.add(scroller, gbc);

    return container;
}

From source file:unikn.dbis.univis.visualization.pivottable.VPivotTable.java

private void createPivotTable(boolean dataOnly) {

    // Removes the scroll pane that contains the pivottable.
    if (tableScrollPane != null) {
        remove(tableScrollPane);// w w  w.ja  v  a2s  . c  o m
    }

    // JTable anlegen mit Daten sowie Ueberschriften
    uniData = new VPivotTableData(cube, measure, function);
    Vector vectorData = uniData.getPivottableData(xAxisDimensions, yAxisDimensions);
    Vector vectorHeader = uniData.getPivottableHeader(xAxisDimensions, yAxisDimensions);

    // Sind denn ueberhaupt Daten zurueckgekommen?
    boolean dataGiven = ((vectorData != null) && (vectorData.size() > 0));
    boolean headerDataGiven = ((vectorHeader != null && vectorHeader.size() > 0));

    if (!dataGiven) {
        System.out.println("keine Daten!");
    }
    if (!headerDataGiven) {
        System.out.println("keine Ueberschriften!");
    }
    if (dataGiven & headerDataGiven) {

        VPivotTableModel modelOrigin = new VPivotTableModel(vectorData, vectorHeader);

        if (dataOnly) {
            tableSorter = new VTableSorter(modelOrigin);
            pivotTable = new JTable(tableSorter);
            tableSorter.setTableHeader(pivotTable.getTableHeader());
        } else {
            VEnvelopeTableModel modelEnv = new VEnvelopeTableModel(modelOrigin);
            pivotTable = new JTable(modelEnv);
            modelEnv.setTableHeader(pivotTable.getTableHeader());
        }

        SimpleRenderer renderer = new VNumberRenderer(false);
        pivotTable.setDefaultRenderer(String.class, renderer);
        // reine Number-Klasse hat Doubles nicht gefaerbt!
        //            pivotTable.setDefaultRenderer(Number.class, renderer);
        pivotTable.setDefaultRenderer(Integer.class, renderer);
        pivotTable.setDefaultRenderer(Long.class, renderer);
        pivotTable.setDefaultRenderer(Double.class, renderer);

        // spezieller CellRenderer fr letzte Total-Spalte
        TableColumn col = pivotTable.getColumnModel().getColumn(vectorHeader.size() - 1);
        col.setCellRenderer(new VTotalCellRenderer());

        /* *** Second Row --> Content Area *** */
        pivotTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

        //Set up tool tips for column headers.
        //            pivotTable.getTableHeader().setToolTipText(
        //                    "Click to specify sorting; Control-Click to specify secondary sorting");

        /* *** Second Row --> Content Area *** */
        pivotTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        tableScrollPane = new JScrollPane(pivotTable);
        tableScrollPane.setVerticalScrollBar(new JScrollBar());

        add(tableScrollPane, BorderLayout.CENTER);

        validate();
        repaint();
    }
}