|
|
发表于 6-2-2010 01:47 PM
|
显示全部楼层
本帖最后由 davidbilly87 于 6-2-2010 02:22 PM 编辑
我看到的都是一些需要
keypress才消失的。。。
可以有自动的吗??
lawty 发表于 5-2-2010 11:39 
我的就是loading完,就自动进另外个function了......
我的class :
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseMotionAdapter;
- /**
- * This class represents an indicator for the startup progress
- *
- * @version 1.0, 25-04-2003
- * @author Logical
- * @see JWindow
- */
- public class SplashScreen extends JWindow
- {
- /* The background image file */
- private static final String bgFile = "SystemPic/SplashScreen2.png";//这个是splash screen的照片URL
- private static Point point = new Point();
- /* The information shown at the top of the screen */
- //private String groupinfo = "<html><body><center><br> </body></html>";
- /* The color of the font shown at the top */
- private Color fontColor = new Color(0, 0, 0);
- /* Shows what is currently loading */
- private JLabel currentLoadedObject = new JLabel();
- /* The progress bar indicating how long it will take before completion */
- private JProgressBar progress = new JProgressBar();
- /**
- * Constructs a loader object to keep track of the progress
- */
- public SplashScreen()
- {
- setSize(480, 350);
- Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
- setLocation((int)(screensize.getWidth()/2)-200, (int)(screensize.getHeight()/2)-125);
- getContentPane().setLayout(new BorderLayout());
- JPanel info = new JPanel();
- info.setLayout(new BorderLayout());
- // JLabel grpInfo = new JLabel(groupinfo, SwingConstants.CENTER);
- // info.add(grpInfo, BorderLayout.NORTH);
- JLabel bg = new JLabel();
- bg.setIcon(new ImageIcon(bgFile));
- info.add(bg, BorderLayout.CENTER);
- getContentPane().add(info, BorderLayout.CENTER);
- JPanel p = new JPanel();
- p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- p.setLayout(new BorderLayout());
- currentLoadedObject.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
- p.add(currentLoadedObject, BorderLayout.WEST);
- progress.setStringPainted(true);
- p.add(progress, BorderLayout.CENTER);
- getContentPane().add(p, BorderLayout.SOUTH);
- setVisible(true);
- }
- /**
- * Let the startup screen disapear
- */
- public void loadingFinished()
- {
- currentLoadedObject.setText("Starting...");
- try{ Thread.sleep(500); }
- catch(InterruptedException e){ e.printStackTrace(); }
- setVisible(false);
- dispose();
-
- }
- public void SystemLogIn ()
- {
- final SystemLogIn frame = new SystemLogIn();//这个是loading完后auto去下个function的
- frame.setLocationRelativeTo(null);
- frame.setVisible(true);
- frame.setIconImage(Toolkit.getDefaultToolkit().getImage("SystemPic/Orange-128.png"));
- /*frame.addMouseListener(new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- point.x = e.getX();
- point.y = e.getY();
- }
- });
- frame.addMouseMotionListener(new MouseMotionAdapter() {
- public void mouseDragged(MouseEvent e) {
- Point p = frame.getLocation();
- frame.setLocation(p.x + e.getX() - point.x,
- p.y + e.getY() - point.y);
- }
- });*/
- }
- /**
- * Constructs the world
- *
- * @param object the object that is currently loading
- * @param maxSteps indicates when the object is 100% loaded
- * @param currentStep indicates how far we are at this moment
- */
- public synchronized void updateLoadingProgress(String object, int maxSteps, int currentStep)
- {
- currentLoadedObject.setText(object);
- //scale
- progress.setMaximum(maxSteps);
- progress.setValue(currentStep);
- }
- public static void main(String[] args)
- {
- SplashScreen loader = new SplashScreen();
- //我放10个loop(每个以10%>20%>30%) , 你可以弄到100都可以
- loader.updateLoadingProgress("Reading data...", 10, 1); goToSleep();
- loader.updateLoadingProgress("Reading data...", 10, 2); goToSleep();
- loader.updateLoadingProgress("Loading System...", 10, 3); goToSleep();
- loader.updateLoadingProgress("Loading System...", 10, 4); goToSleep();
- loader.updateLoadingProgress("Loading System...", 10, 5); goToSleep();
- loader.updateLoadingProgress("Loading System...", 10, 6); goToSleep();
- loader.updateLoadingProgress("Preparing...", 10, 7); goToSleep();
- loader.updateLoadingProgress("Preparing...", 10, 8); goToSleep();
- loader.updateLoadingProgress("Preparing...", 10, 9); goToSleep();
- loader.updateLoadingProgress("Starting...", 10, 10); goToSleep();
- loader.loadingFinished();
- loader.SystemLogIn();
- }
- public static void goToSleep()
- {
- try{ Thread.currentThread().sleep(550);}//550 value 你要 每隔 loading%到另个loading delay ms
- catch(Exception e){}
- }
- }
复制代码
你自己慢慢研究..... |
|