ErSKS / Java

Java Training
http://khec.edu.np/
MIT License
16 stars 17 forks source link

Splash Screen - Loading #69

Closed ErSKS closed 7 years ago

ErSKS commented 7 years ago

Gif Image: loading

JFrame Code: Loading.zip

Useful Code Inside Loading.java:

private void formWindowOpened(java.awt.event.WindowEvent evt) {
timer = new Timer(50, new Progress()); timer.start(); }

public int n; public Timer timer;

public class Progress implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent evt) {
        if (n < 100) {
            n++;
            lblPerc.setText("" + n + "%");
        } else {
            timer.stop();
            Login log = new Login();
            log.setVisible(true);
            dispose();
        }
    }
}