我创建了一个带有 CustomScrollBarUI 类的 Swing 应用程序。但是在ofuscation之后程序没有按预期工作。Scrollpane UI没有改变。UIManager.put("ScrollBarUI", CustomScrollPaneUI.class.getName());
在主中添加。任何有解决方案的人请帮助...在此先感谢。(ProGuard用于滥用)
public class CustomScrollPaneUI extends BasicScrollBarUI {
public static ComponentUI createUI(JComponent c) {
return new CustomScrollPaneUI();
}
protected JButton createDecreaseButton(int orientation) {
return new BasicArrowButton(orientation, Color.white, Color.white, Color.black, Color.white);
}
protected JButton createIncreaseButton(int orientation) {
return new BasicArrowButton(orientation, Color.white, Color.white, Color.black, Color.white);
}
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
g.setColor(Color.black);
g.drawRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height);
g.setColor(Color.white);
g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height);
if (trackHighlight == DECREASE_HIGHLIGHT) {
paintDecreaseHighlight(g);
} else if (trackHighlight == INCREASE_HIGHLIGHT) {
paintIncreaseHighlight(g);
}
}
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
return;
}
Graphics2D g2 = (Graphics2D) g;
int w = thumbBounds.width;
int h = thumbBounds.height;
GradientPaint gradientPaint = new GradientPaint(0, w, Color.gray, w, h, Color.lightGray);
g.translate(thumbBounds.x, thumbBounds.y);
g.drawRoundRect(0, 0, w, h, 5, 5);
g2.setPaint(gradientPaint);
g.fillRoundRect(0, 0, w, h, 5, 5);
g2.setPaint(gradientPaint);
g.translate(-thumbBounds.x, -thumbBounds.y);
}}