javax.swing.plaf.basic.BasicScrollBarUI Java Examples

The following examples show how to use javax.swing.plaf.basic.BasicScrollBarUI. 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: JBScrollPane.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static boolean canBePreprocessed(MouseEvent e, JScrollBar bar) {
  if (e.getID() == MouseEvent.MOUSE_MOVED || e.getID() == MouseEvent.MOUSE_PRESSED) {
    ScrollBarUI ui = bar.getUI();
    if (ui instanceof BasicScrollBarUI) {
      BasicScrollBarUI bui = (BasicScrollBarUI)ui;
      try {
        Rectangle rect = (Rectangle)ReflectionUtil.getDeclaredMethod(BasicScrollBarUI.class, "getThumbBounds", ArrayUtil.EMPTY_CLASS_ARRAY).invoke(bui);
        Point point = SwingUtilities.convertPoint(e.getComponent(), e.getX(), e.getY(), bar);
        return !rect.contains(point);
      }
      catch (Exception e1) {
        return true;
      }
    }
  }
  return true;
}
 
Example #2
Source File: FlatScrollBarUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected PropertyChangeListener createPropertyChangeListener() {
	return new BasicScrollBarUI.PropertyChangeHandler() {
		@Override
		public void propertyChange( PropertyChangeEvent e ) {
			super.propertyChange( e );

			switch( e.getPropertyName() ) {
				case FlatClientProperties.SCROLL_BAR_SHOW_BUTTONS:
					scrollbar.revalidate();
					scrollbar.repaint();
					break;

				case "componentOrientation":
					// this is missing in BasicScrollBarUI.Handler.propertyChange()
					InputMap inputMap = (InputMap) UIManager.get( "ScrollBar.ancestorInputMap" );
					if( !scrollbar.getComponentOrientation().isLeftToRight() ) {
						InputMap rtlInputMap = (InputMap) UIManager.get( "ScrollBar.ancestorInputMap.RightToLeft" );
						if( rtlInputMap != null ) {
							rtlInputMap.setParent( inputMap );
							inputMap = rtlInputMap;
						}
					}
					SwingUtilities.replaceUIInputMap( scrollbar, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap );
					break;
			}
		}
	};
}
 
Example #3
Source File: DarculaScrollBarUI.java    From Darcula with Apache License 2.0 4 votes vote down vote up
public static BasicScrollBarUI createNormal() {
  return new DarculaScrollBarUI();
}