Java Code Examples for javax.swing.JScrollBar#setValues()

The following examples show how to use javax.swing.JScrollBar#setValues() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfilerTableContainer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void updateHorizontalScrollBars(ProfilerTable table, int column, boolean layout) {
    if (column != -1) {
        JScrollBar scroll = getScroller(column);
        int offset = table.getColumnOffset(column);
        int columnPref = table.getColumnPreferredWidth(column);
        int _column = table.convertColumnIndexToView(column);
        int columnAct = table.getTableHeader().getHeaderRect(_column).width;
        if (columnPref > columnAct) {
            int value = Math.min(offset, columnPref - columnAct);
            scroll.setValues(value, columnAct, 0, columnPref);
        } else {
            scroll.setValues(0, 0, 0, 0);
        }
    }
    
    if (layout) {
        doLayout();
        scrollersPanel.doLayout();
        repaint();
    }
}
 
Example 2
Source File: ProfilerTableContainer.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void updateHorizontalScrollBars(ProfilerTable table, int column, boolean layout) {
    if (column != -1) {
        JScrollBar scroll = getScroller(column);
        int offset = table.getColumnOffset(column);
        int columnPref = table.getColumnPreferredWidth(column);
        int _column = table.convertColumnIndexToView(column);
        int columnAct = table.getTableHeader().getHeaderRect(_column).width;
        if (columnPref > columnAct) {
            int value = Math.min(offset, columnPref - columnAct);
            scroll.setValues(value, columnAct, 0, columnPref);
        } else {
            scroll.setValues(0, 0, 0, 0);
        }
    }
    
    if (layout) {
        doLayout();
        scrollersPanel.doLayout();
        repaint();
    }
}
 
Example 3
Source File: DirectScrollPanel.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
private static void syncScrollBar(JScrollBar bar, int available, int needed) {
    bar.setValues(available < needed ? Math.min(bar.getValue(), needed - available) : 0, available, 0, needed);
}