开发者

Java Swing - ImageIcon in Jtable within a JScrollPane

I have a JTable inside a JScrollPane. In one of the columns in the JTable, I have ImageIcons being displayed. Everything works fine, however, I have 开发者_Go百科that in windows XP, when you scroll the rendering messes up and images become distorted.

This only happens when you scroll.

Screenshot: http://i.stack.imgur.com/NKqYT.png

Any help much appreciated!


Add an adjustment listener to your scroll bar and repaint the table on ajustment value changed events.

scrollBar=new JScrollPane(table);
scrollBar.getVerticalScrollBar().addAdjustmentListener(this);

public void adjustmentValueChanged(AdjustmentEvent e) {
    table.repaint();

    }


Images display fine on XP. Try out the example from UIManager Defaults. Click on "By Value Type" and then select "Icons" from the combo box.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜