开发者

Java Swing - ImageIcon in Jtable within a JScrollPane

开发者 https://www.devze.com 2023-01-11 20:28 出处:网络
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 th

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

精彩评论

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

关注公众号