Bitcoin

Bitcoin
Bitcoin

A Splash Screen which loads a login page by implementing runnables

package Execute;

import java.awt.Color;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JWindow;
import javax.swing.JLabel;
import javax.swing.ImageIcon; 
import javax.swing.JProgressBar; 
import javax.swing.Box; 
import javax.swing.border.Border;

public final class Splash implements Runnable{
    JWindow win;
    Toolkit kit=Toolkit.getDefaultToolkit();
    Image img;
    JLabel lab;
    ImageIcon ico;
    JProgressBar pr;
    Box b=Box.createVerticalBox();

    public Splash(String file){
        start();
        win=new JWindow();
        pr=new JProgressBar(0,100);//the animated progressbar
        Border bor=BorderFactory.createEtchedBorder(5, Color.lightGray, Color.yellow);//Border color
        ico=new ImageIcon(file);//adding image using an imageicon class
        lab=new JLabel();//label added to the JWindow
        lab.setIcon(ico);//Sets the icon of the label as the imageicon
        pr.setStringPainted(true);//Setting the progressBar visible
        b.add(lab);
        b.add(pr);
        b.setBorder(bor);//Sets the border of the Box that contains other java objects
        win.add(b);
        win.setSize(300,200);//Sets the size of the JWindow
        win.setLocation(400,200);//set the location of the JWindow to be displayed
        win.setVisible(true);//Set JWindow visible
    }
    public static void main(String[] arg){
        new Splash();
    }
    public void run() {
        try{
            int current=0;
            for(int i=0;i<=100;i++){
                current=i;
                pr.setValue(current);
                Thread.sleep(30);
            }
            if(current == 100){
                home = new Login();//run this when the splash screen reaches hundred
                home.setTitle("THE LOGIN PAGE THAT ENABLES YOU MAKE USE OF THE APPLICATION");
                home.setVisible(true); set the login page true
                win.setVisible(false);//sets the splash screen visibility false
            }
        }
        catch(Exception e){
              e.printStackTrace();
         }
    }
    public void start(){
        Thread tr=new Thread(this);
        tr.start();
    }
    private Login home;
}

No comments:

Post a Comment

Facebook