@Override protected JScrollBar createScrollBar() { JBScrollBar bar = new JBScrollBar(); bar.putClientProperty(JBScrollPane.Alignment.class, JBScrollPane.Alignment.RIGHT); bar.putClientProperty(JBScrollBar.TRACK, new RegionPainter<Object>() { @Override public void paint(Graphics2D g, int x, int y, int width, int height, Object object) { SubstringFinder.FindResult result = myTerminalPanel.getFindResult(); if (result != null) { int modelHeight = bar.getModel().getMaximum() - bar.getModel().getMinimum(); int anchorHeight = Math.max(2, height / modelHeight); Color color = mySettingsProvider.getTerminalColorPalette() .getColor(mySettingsProvider.getFoundPatternColor().getBackground()); g.setColor(color); for (SubstringFinder.FindResult.FindItem r : result.getItems()) { int where = height * r.getStart().y / modelHeight; g.fillRect(x, y + where, width, anchorHeight); } } } }); return bar; }
@Override protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { if (alwaysShowTrack() || myMouseOverScrollbarExpandLevel > 0) { doPaintTrack(g, c, trackBounds); } RegionPainter<Object> painter = UIUtil.getClientProperty(c, JBScrollBar.TRACK); if (painter != null) { painter.paint((Graphics2D)g, trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height, null); } }
@Override protected JScrollBar createScrollBar() { return new JBScrollBar(); }