javax.swing.plaf.basic.BasicScrollPaneUI Java Examples

The following examples show how to use javax.swing.plaf.basic.BasicScrollPaneUI. 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: FlatScrollPaneUI.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
@Override
protected MouseWheelListener createMouseWheelListener() {
	return new BasicScrollPaneUI.MouseWheelHandler() {
		@Override
		public void mouseWheelMoved( MouseWheelEvent e ) {
			// Note: Getting UI value "ScrollPane.smoothScrolling" here to allow
			// applications to turn smooth scrolling on or off at any time
			// (e.g. in application options dialog).
			if( UIManager.getBoolean( "ScrollPane.smoothScrolling" ) &&
				scrollpane.isWheelScrollingEnabled() &&
				e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL &&
				e.getPreciseWheelRotation() != 0 &&
				e.getPreciseWheelRotation() != e.getWheelRotation() )
			{
				mouseWheelMovedSmooth( e );
			} else
				super.mouseWheelMoved( e );
		}
	};
}
 
Example #2
Source File: FlatScrollPaneUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected PropertyChangeListener createPropertyChangeListener() {
	return new BasicScrollPaneUI.PropertyChangeHandler() {
		@Override
		public void propertyChange( PropertyChangeEvent e ) {
			super.propertyChange( e );

			switch( e.getPropertyName() ) {
				case FlatClientProperties.SCROLL_BAR_SHOW_BUTTONS:
					JScrollBar vsb = scrollpane.getVerticalScrollBar();
					JScrollBar hsb = scrollpane.getHorizontalScrollBar();
					if( vsb != null ) {
						vsb.revalidate();
						vsb.repaint();
					}
					if( hsb != null ) {
						hsb.revalidate();
						hsb.repaint();
					}
					break;

				case ScrollPaneConstants.LOWER_LEFT_CORNER:
				case ScrollPaneConstants.LOWER_RIGHT_CORNER:
				case ScrollPaneConstants.UPPER_LEFT_CORNER:
				case ScrollPaneConstants.UPPER_RIGHT_CORNER:
					// remove border from buttons added to corners
					Object corner = e.getNewValue();
					if( corner instanceof JButton &&
						((JButton)corner).getBorder() instanceof FlatButtonBorder &&
						scrollpane.getViewport() != null &&
						scrollpane.getViewport().getView() instanceof JTable )
					{
						((JButton)corner).setBorder( BorderFactory.createEmptyBorder() );
						((JButton)corner).setFocusable( false );
					}
				break;
			}
		}
	};
}