Search in sources :

Example 1 with BasicScrollBarUI

use of javax.swing.plaf.basic.BasicScrollBarUI in project intellij-community by JetBrains.

the class JBScrollPane method canBePreprocessed.

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;
            }
        } else if (ui instanceof DefaultScrollBarUI) {
            DefaultScrollBarUI dui = (DefaultScrollBarUI) ui;
            Point point = e.getLocationOnScreen();
            SwingUtilities.convertPointFromScreen(point, bar);
            return !dui.isThumbContains(point.x, point.y);
        }
    }
    return true;
}
Also used : BasicScrollBarUI(javax.swing.plaf.basic.BasicScrollBarUI) ButtonlessScrollBarUI(com.intellij.util.ui.ButtonlessScrollBarUI) BasicScrollBarUI(javax.swing.plaf.basic.BasicScrollBarUI) ScrollBarUI(javax.swing.plaf.ScrollBarUI)

Aggregations

ButtonlessScrollBarUI (com.intellij.util.ui.ButtonlessScrollBarUI)1 ScrollBarUI (javax.swing.plaf.ScrollBarUI)1 BasicScrollBarUI (javax.swing.plaf.basic.BasicScrollBarUI)1