0

I am a Beginner in Java GUI, I am trying to show the user a splashScreen which will show him/her the Progress done, I tried doing it with Graphics2D, but the problem is that the class paints the screen very slowly, I did it using a for loop for animations but even without using the Thread.sleep() function the for loop is even slowed, Here is my code:

int wpro = 0,prox = 491, proy = 389;
Graphics2D pro1 = splash.createGraphics();
pro1.setComposite(AlphaComposite.Clear);
pro1.setPaintMode();
pro1.setColor(Color.WHITE);
pro1.setBackground(Color.WHITE);
wpro = 52;
for (int i = 0; i <= wpro; i++) {
    pro1.drawRect(prox, proy, i, 4);
    splash.update();
}

If anyone can help me out either by giving me an alternate way or pointing out my mistake. Thanks in advance for any help!

4

0 回答 0