boolean (JScrollBar scrollbar) { Window window = (Window)scrollbar.getTopLevelAncestor(); if (window instanceof JDialog && "Commit Changes".equals(((JDialog)window).getTitle())) { return false; } if (!(window instanceof RootPaneContainer)) { return true; } Component[] components = ((RootPaneContainer)window).getContentPane().getComponents(); if (components.length == 1 && components[0].getClass().getName().contains("DiffWindow")) { return false; } if (components.length == 2 && components[0] instanceof Container) { Component[] subComponents = ((Container)components[0]).getComponents(); if (subComponents.length == 1) { String name = subComponents[0].getClass().getName(); if (name.contains("DiffWindow") || name.contains("MergeWindow")) { return false; } } } return true; }