JScrollBar () { JBScrollBar bar = new JBScrollBar() { @Override public Color getBackground() { return myTerminalPanel.getBackground(); } }; bar.setOpaque(true); bar.putClientProperty(JBScrollPane.Alignment.class, JBScrollPane.Alignment.RIGHT); bar.putClientProperty(JBScrollBar.TRACK, (RegionPainter<Object>)(g, x, y, width, height, object) -> { SubstringFinder.FindResult result = myTerminalPanel.getFindResult(); if (result != null) { int modelHeight = bar.getModel().getMaximum() - bar.getModel().getMinimum(); TerminalColor backgroundColor = mySettingsProvider.getFoundPatternColor().getBackground(); if (backgroundColor != null) { g.setColor(AwtTransformers.toAwtColor(mySettingsProvider.getTerminalColorPalette().getBackground(backgroundColor))); } int anchorHeight = Math.max(2, height / modelHeight); for (SubstringFinder.FindResult.FindItem r : result.getItems()) { int where = height * r.getStart().y / modelHeight; g.fillRect(x, y + where, width, anchorHeight); } } }); return bar; }