0

I am using the validation api from here http://java.dzone.com/news/how-quickly-add-validation. 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.

    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??

Jany Gwan
  • 77
  • 1
  • 2
  • 9
  • Look into [Validate vs Revalidate vs Invalidate](http://stackoverflow.com/questions/9510125/difference-between-validate-revalidate-and-invalidate-in-swing-gui). It's possible you only need to use validate. – pietas Mar 26 '15 at 18:46
  • After some reading and efforts.. i decided to edit the jar file and remove the icons altogether... then redraw them myself after replacing the panel in my card layout. – Jany Gwan Apr 03 '15 at 12:22

1 Answers1

0

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..

Jany Gwan
  • 77
  • 1
  • 2
  • 9