简体   繁体   English

Java重绘在JscrollPane中不起作用

[英]Java repaint not working in JscrollPane

I am using the validation api from here http://java.dzone.com/news/how-quickly-add-validation . 我正在从此处http://java.dzone.com/news/how-quickly-add-validation使用验证API。 It works okay when i put all my components in a panel.However,if my components are in a panel wrapped in a Jscrollpane,the red validation error icons remain static as i scroll.I have tried to do a revalidate and repaint(on the adjustment listener) to no avail. 当我将所有组件放在面板中时,它可以正常工作。但是,如果我的组件位于包裹在Jscrollpane中的面板中,则当我滚动时,红色验证错误图标将保持静态。我尝试进行重新验证和重新绘制(在调整监听器)无济于事。

    majorPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener(){
        @Override
        public void adjustmentValueChanged(AdjustmentEvent e) {


            frame.revalidate();
            frame.repaint();

        }
    });

However,if i resize the screen,the icons flow to the correct location.For experiments sake. 但是,如果我调整屏幕大小,图标将流到正确的位置。出于实验目的。 i did the following..slightly force a resize,and now it works..However that little resize is still visible and annoying... 我做了以下..稍微强行调整大小,现在就可以了。.但是,这种小的调整仍然可见且令人讨厌...

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int ScreenWidth = (int) screenSize.getWidth();
    int ScreenHeight = (int) screenSize.getHeight();
    majorPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener(){
        @Override
        public void adjustmentValueChanged(AdjustmentEvent e) {

            frame.setSize(ScreenWidth-15, ScreenHeight-15);
            frame.setExtendedState(Resource.MAXIMIZED_BOTH);

            frame.revalidate();
            frame.repaint();

        }
    });

So How can i force a repaint as effective as the resize??? 那么我该如何强制重新绘制与调整大小一样有效呢??? or any better suggestions?? 或任何更好的建议?

The validation plugin was not properly done it seems. 验证插件似乎未正确完成。 Only works well in panels,not in Jscrollpane.The best was to remove the icons and draw them by myself..thanks.. 只能在面板中正常工作,而不能在Jscrollpane中工作。最好的办法是删除图标并自己绘制它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM