Java Code Examples for javax.swing.JScrollPane#setVerticalScrollBar()

The following examples show how to use javax.swing.JScrollPane#setVerticalScrollBar() . 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: XDMComboBoxUI.java    From xdm with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected ComboPopup createPopup() {
	return new BasicComboPopup(comboBox) {
		/**
		 * 
		 */
		private static final long serialVersionUID = -4232501153552563408L;

		@Override
		protected JScrollPane createScroller() {
			JScrollPane scroller = new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
					JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
			scroller.setVerticalScrollBar(new DarkScrollBar(JScrollBar.VERTICAL));
			return scroller;
		}
	};
}
 
Example 2
Source File: SettingsPage.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
public SettingsPage() {
	setOpaque(false);
	setLayout(null);
	bgColor = new Color(0, 0, 0, Config.getInstance().isNoTransparency() ? 255 : 200);
	MouseInputAdapter ma = new MouseInputAdapter() {
	};

	addMouseListener(ma);
	addMouseMotionListener(ma);

	jsp = new JScrollPane();
	jsp.setOpaque(false);
	jsp.setBorder(null);
	jsp.getViewport().setOpaque(false);

	DarkScrollBar scrollBar = new DarkScrollBar(JScrollBar.VERTICAL);
	jsp.setVerticalScrollBar(scrollBar);
	jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jsp.getVerticalScrollBar().setUnitIncrement(getScaledInt(10));
	jsp.getVerticalScrollBar().setBlockIncrement(getScaledInt(25));

	add(jsp);

	registerMouseListener();

	init();

	pageStack = new ArrayList<JPanel>();
}
 
Example 3
Source File: Page.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
public Page(String title, int width, XDMFrame parent) {
	setOpaque(false);
	setLayout(null);
	this.title = title;
	this.width = width;
	this.parent = parent;
	bgColor = new Color(0, 0, 0, Config.getInstance().isNoTransparency()?255:200);
	MouseInputAdapter ma = new MouseInputAdapter() {
	};

	addMouseListener(ma);
	addMouseMotionListener(ma);

	jsp = new JScrollPane();
	jsp.setOpaque(false);
	jsp.setBorder(null);
	jsp.getViewport().setOpaque(false);

	DarkScrollBar scrollBar = new DarkScrollBar(JScrollBar.VERTICAL);
	jsp.setVerticalScrollBar(scrollBar);
	jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	jsp.getVerticalScrollBar().setUnitIncrement(getScaledInt(10));
	jsp.getVerticalScrollBar().setBlockIncrement(getScaledInt(25));

	add(jsp);

	registerMouseListener();

	init();

}
 
Example 4
Source File: ScrollPanel.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
public ScrollPanel(LogFrame frame) {
	super(frame);
	this.table = new TablePanel(frame);
	JScrollPane pane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	pane.setVerticalScrollBar(table.getVerticalScrollBar());
	setLayout(new BorderLayout());
	add(pane);
}
 
Example 5
Source File: DetailsPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void initComponents() {        
    table = new DetailsTable();
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JViewport viewport = new Viewport(table);

    final JScrollPane tableScroll = new JScrollPane(
                                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScroll.setViewport(viewport);
    tableScroll.setBorder(BorderFactory.createEmptyBorder());
    tableScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel());
    
    scrollBar = new ScrollBar(JScrollBar.VERTICAL) {
        public int getUnitIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableUnitIncrement(vr, getOrientation(), direction);
        }
        public int getBlockIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableBlockIncrement(vr, getOrientation(), direction);
        }
        public void setValues(int newValue, int newExtent, int newMin, int newMax) {
            setEnabled(newExtent < newMax);
            if (isEnabled() && !isSelectionChanging() && isTrackingEnd())
                newValue = newMax - newExtent;
            super.setValues(newValue, newExtent, newMin, newMax);
        }
    };
    tableScroll.setVerticalScrollBar(scrollBar);
    dataContainer = tableScroll;

    JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER);
    noDataLabel.setEnabled(false);
    noDataContainer = new JPanel(new BorderLayout());
    noDataContainer.setOpaque(false);
    noDataContainer.add(noDataLabel, BorderLayout.CENTER);

    setOpaque(false);
    setLayout(new BorderLayout());
    add(noDataContainer, BorderLayout.CENTER);
}
 
Example 6
Source File: DetailsPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {        
    table = new DetailsTable();
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JViewport viewport = new Viewport(table);

    final JScrollPane tableScroll = new JScrollPane(
                                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScroll.setViewport(viewport);
    tableScroll.setBorder(BorderFactory.createEmptyBorder());
    tableScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel());
    
    scrollBar = new ScrollBar(JScrollBar.VERTICAL) {
        public int getUnitIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableUnitIncrement(vr, getOrientation(), direction);
        }
        public int getBlockIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableBlockIncrement(vr, getOrientation(), direction);
        }
        public void setValues(int newValue, int newExtent, int newMin, int newMax) {
            setEnabled(newExtent < newMax);
            if (isEnabled() && !isSelectionChanging() && isTrackingEnd())
                newValue = newMax - newExtent;
            super.setValues(newValue, newExtent, newMin, newMax);
        }
    };
    tableScroll.setVerticalScrollBar(scrollBar);
    dataContainer = tableScroll;

    JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER);
    noDataLabel.setEnabled(false);
    noDataContainer = new JPanel(new BorderLayout());
    noDataContainer.setOpaque(false);
    noDataContainer.add(noDataLabel, BorderLayout.CENTER);

    setOpaque(false);
    setLayout(new BorderLayout());
    add(noDataContainer, BorderLayout.CENTER);
}
 
Example 7
Source File: DetailsPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {        
    table = new DetailsTable();
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JViewport viewport = new Viewport(table);

    final JScrollPane tableScroll = new JScrollPane(
                                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScroll.setViewport(viewport);
    tableScroll.setBorder(BorderFactory.createEmptyBorder());
    tableScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel());
    
    scrollBar = new ScrollBar(JScrollBar.VERTICAL) {
        public int getUnitIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableUnitIncrement(vr, getOrientation(), direction);
        }
        public int getBlockIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableBlockIncrement(vr, getOrientation(), direction);
        }
        public void setValues(int newValue, int newExtent, int newMin, int newMax) {
            setEnabled(newExtent < newMax);
            if (isEnabled() && !isSelectionChanging() && isTrackingEnd())
                newValue = newMax - newExtent;
            super.setValues(newValue, newExtent, newMin, newMax);
        }
    };
    tableScroll.setVerticalScrollBar(scrollBar);
    dataContainer = tableScroll;

    JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER);
    noDataLabel.setEnabled(false);
    noDataContainer = new JPanel(new BorderLayout());
    noDataContainer.setOpaque(false);
    noDataContainer.add(noDataLabel, BorderLayout.CENTER);

    setOpaque(false);
    setLayout(new BorderLayout());
    add(noDataContainer, BorderLayout.CENTER);
}