Example usage for javax.swing JScrollPane setHorizontalScrollBar

List of usage examples for javax.swing JScrollPane setHorizontalScrollBar

Introduction

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

Prototype

@BeanProperty(expert = true, description = "The horizontal scrollbar.")
public void setHorizontalScrollBar(JScrollBar horizontalScrollBar) 

Source Link

Document

Adds the scrollbar that controls the viewport's horizontal view position to the scrollpane.

Usage

From source file:org.openmicroscopy.shoola.agents.measurement.view.IntensityView.java

/**
 * Create the table panel which holds all the intensities for the selected
 * channel in the table./*from www. j a  v  a  2 s.co m*/
 * @return See Above.
 */
private JPanel tablePanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JScrollPane scrollPane = new JScrollPane(channelSummaryTable);
    scrollPane.setVerticalScrollBar(scrollPane.createVerticalScrollBar());
    scrollPane.setHorizontalScrollBar(scrollPane.createHorizontalScrollBar());
    panel.add(scrollPane);
    return panel;
}

From source file:org.ut.biolab.medsavant.client.view.list.ListView.java

private void updateShowCard() {
    showCard.removeAll();//from  w  w w.j a va  2s. co m

    showCard.setLayout(new BorderLayout());

    String[] columnNames = detailedModel.getColumnNames();
    Class[] columnClasses = detailedModel.getColumnClasses();
    int[] columnVisibility = detailedModel.getHiddenColumns();

    int firstVisibleColumn = 0;
    while (columnVisibility.length > 0 && firstVisibleColumn == columnVisibility[firstVisibleColumn]) {
        firstVisibleColumn++;
    }

    Set<NiceListItem> selectedItems;
    if (list != null) {
        selectedItems = new HashSet<NiceListItem>(list.getSelectedItems());
    } else {
        selectedItems = new HashSet<NiceListItem>(); // empty set, for simplicity of not having to null check later on
    }

    list = new NiceList();
    if (listColorScheme != null) {
        list.setColorScheme(listColorScheme);
    }
    list.startTransaction();

    List<Integer> selectedIndicies = new ArrayList<Integer>();

    int counter = 0;
    for (Object[] row : data) {
        NiceListItem nli = new NiceListItem(row[firstVisibleColumn].toString(), row);
        list.addItem(nli);

        if (selectedItems.contains(nli)) {
            selectedIndicies.add(counter);
        }
        counter++;
    }

    /*
     int[] selectedIndiciesArray = new int[selectedIndicies.size()];
            
     System.out.println("Reselecting "  + selectedIndicies.size() + " items");
     for (int i = 0; i < selectedIndicies.size();i++) {
     System.out.println("Reselecting "  + list.getItem(selectedIndicies.get(i)).toString() + " at index " + selectedIndicies.get(i));
     selectedIndiciesArray[i] = selectedIndicies.get(i);
     }*/
    list.endTransaction();

    wp.setBackground(list.getColorScheme().getBackgroundColor());

    if (detailedView != null) {
        list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {

                if (!e.getValueIsAdjusting()) {
                    List<Object[]> selectedItems = getSelectedRows();
                    if (selectedItems.size() == 1) {
                        detailedView.setSelectedItem(selectedItems.get(0));
                    } else {
                        detailedView.setMultipleSelections(selectedItems);
                    }
                }
            }
        });

        list.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                if (SwingUtilities.isRightMouseButton(e)) {
                    JPopupMenu popup = detailedView.createPopup();
                    if (popup != null) {
                        popup.show(e.getComponent(), e.getX(), e.getY());
                    }
                }
            }
        });
    }

    if (selectedIndicies.isEmpty()) {
        list.selectItemAtIndex(0);
    } else {
        list.selectItemsAtIndicies(selectedIndicies);
    }

    JScrollPane jsp = ViewUtil.getClearBorderlessScrollPane(list);
    jsp.setHorizontalScrollBar(null);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new MigLayout("wrap, fillx"));

    topPanel.add(ViewUtil.getEmphasizedLabel(pageName.toUpperCase()));
    topPanel.setBackground(list.getColorScheme().getBackgroundColor());

    if (searchBarEnabled) {
        topPanel.add(list.getSearchBar(), "growx 1.0");
    }
    showCard.add(topPanel, BorderLayout.NORTH);

    showCard.add(jsp, BorderLayout.CENTER);

    showCard.add(controlBar.getComponent(), BorderLayout.SOUTH);

}

From source file:org.yccheok.jstock.gui.AjaxAutoCompleteJComboBox.java

private void adjustScrollBar() {
    final int max_search = 8;
    // i < max_search is just a safe guard when getAccessibleChildrenCount
    // returns an arbitary large number. 8 is magic number
    JPopupMenu popup = null;// w  w  w .  ja v a  2 s  . c o m
    for (int i = 0, count = this.getUI().getAccessibleChildrenCount(this); i < count && i < max_search; i++) {
        Object o = this.getUI().getAccessibleChild(this, i);
        if (o instanceof JPopupMenu) {
            popup = (JPopupMenu) o;
            break;
        }
    }
    if (popup == null) {
        return;
    }
    JScrollPane scrollPane = null;
    for (int i = 0, count = popup.getComponentCount(); i < count && i < max_search; i++) {
        Component c = popup.getComponent(i);
        if (c instanceof JScrollPane) {
            scrollPane = (JScrollPane) c;
            break;
        }
    }
    if (scrollPane == null) {
        return;
    }
    scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}