1

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);
}}
4

2 に答える 2