Below is the Example that shows the splash screen without using any special class:
import javax.swing.*;
import java.awt.*;
import java.awt.event .*;
import java.io.*;
import javax.swing.border.*;
public class Splash
{
JFrame frame;
JPanel jf;
JLabel lb,imglb,locklb;
JPasswordField pw;
Splash()
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch(Exception e){}
frame=new JFrame("Splash");
jf=new JPanel();
lb=new JLabel("Enter Password:");
imglb=new JLabel(new ImageIcon(".//bg.gif"));
pw=new JPasswordField();
pw.setFont(new Font("comic sans ms",Font.BOLD,18));
jf.setLayout(null);
lb.setBounds(265,30,150,30);
lb.setForeground(Color.white);
lb.setFont(new Font("Comic Sans ms",Font.BOLD,18));
imglb.setBounds(0,0,480,200);
Border blackline = BorderFactory.createLineBorder(Color.red);
imglb.setBorder(blackline);
pw.setBounds(250,60,180,30);
jf.add(lb);
jf.add(pw);
jf.add(imglb);
frame.add(jf);
frame.setSize(480,200);
frame.setLocation(350,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setUndecorated(true);
try
{
JFrame sframe=new JFrame("Splash");
JPanel jp=new JPanel();
JLabel lb=new JLabel("Loading.........");
jp.setLayout(null);
JLabel piclb=new JLabel(new ImageIcon(".//splash.gif"));
piclb.setBounds(0,0,300,200);
lb.setBounds(10,200,300,25);
jp.add(piclb);
jp.add(lb);
lb.setFont(new Font("Comic Sans Ms",Font.BOLD,20));
jp.setBackground(Color.white);
sframe.add(jp);
sframe.setResizable(false);
sframe.setSize(350,240);
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width-300)/2;
int y = (screen.height-200)/2;
sframe.setLocation(x,y);
sframe.setUndecorated(true);
sframe.setVisible(true);
String st="Loading..."+".";
for(int i=0;i<15;i++)
{
st+=".";
lb.setText(st);
Thread.sleep(700);
}
sframe.setVisible(false);
frame.setVisible(true);
}catch(Exception e){System.out.println("exception in login splash:"+e);}
}
public static void main(String... s)
{
new Splash();
}
}//end class
Download
0 comments:
Post a Comment