佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 869|回复: 4

j2me 等待的screen

[复制链接]
发表于 4-2-2010 09:54 PM | 显示全部楼层 |阅读模式
请问要怎么弄一个loading的screen.....
小弟已经试了很多天都不可以。。。。

通常用在login那里的。。。
当用户要登入的时候,
先显示那个loading。。。
然后才进到里面。。。。。。

就是那个loading screen 小弟我弄不到。。。。。

请大大们帮忙。。。。。。。

谢谢。。。。
回复

使用道具 举报


ADVERTISEMENT

发表于 5-2-2010 02:29 AM | 显示全部楼层
google java "splash screen" 就有了...我有做过在我的FYP里...
回复

使用道具 举报

 楼主| 发表于 5-2-2010 11:39 AM | 显示全部楼层
我看到的都是一些需要
keypress才消失的。。。
可以有自动的吗??
回复

使用道具 举报

发表于 6-2-2010 01:47 PM | 显示全部楼层
本帖最后由 davidbilly87 于 6-2-2010 02:22 PM 编辑
我看到的都是一些需要
keypress才消失的。。。
可以有自动的吗??
lawty 发表于 5-2-2010 11:39




我的就是loading完,就自动进另外个function了......


我的class :


  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.MouseAdapter;
  4. import java.awt.event.MouseEvent;
  5. import java.awt.event.MouseMotionAdapter;

  6. /**
  7. * This class represents an indicator for the startup progress
  8. *
  9. * @version   1.0, 25-04-2003
  10. * @author    Logical
  11. * @see       JWindow
  12. */

  13. public class SplashScreen extends JWindow
  14. {
  15.    /* The background image file */
  16.    private static final String bgFile = "SystemPic/SplashScreen2.png";//这个是splash screen的照片URL
  17.    private static Point point = new Point();
  18.    /* The information shown at the top of the screen */
  19.    //private String groupinfo = "<html><body><center><br> </body></html>";

  20.    /* The color of the font shown at the top */
  21.    private Color fontColor = new Color(0, 0, 0);

  22.    /* Shows what is currently loading */
  23.    private JLabel currentLoadedObject = new JLabel();

  24.    /* The progress bar indicating how long it will take before completion */
  25.    private JProgressBar progress = new JProgressBar();

  26.    /**
  27.    * Constructs a loader object to keep track of the progress
  28.    */
  29.    public SplashScreen()
  30.    {
  31.       setSize(480, 350);
  32.       Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
  33.       setLocation((int)(screensize.getWidth()/2)-200, (int)(screensize.getHeight()/2)-125);
  34.       getContentPane().setLayout(new BorderLayout());

  35.       JPanel info = new JPanel();
  36.       info.setLayout(new BorderLayout());

  37. //      JLabel grpInfo = new JLabel(groupinfo, SwingConstants.CENTER);
  38.      // info.add(grpInfo, BorderLayout.NORTH);

  39.       JLabel bg = new JLabel();
  40.       bg.setIcon(new ImageIcon(bgFile));
  41.       info.add(bg, BorderLayout.CENTER);

  42.       getContentPane().add(info, BorderLayout.CENTER);

  43.       JPanel p = new JPanel();
  44.       p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  45.       p.setLayout(new BorderLayout());
  46.       currentLoadedObject.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
  47.       p.add(currentLoadedObject, BorderLayout.WEST);
  48.       progress.setStringPainted(true);
  49.       p.add(progress, BorderLayout.CENTER);

  50.       getContentPane().add(p, BorderLayout.SOUTH);

  51.       setVisible(true);
  52.    }

  53.    /**
  54.    * Let the startup screen disapear
  55.    */
  56.    public void loadingFinished()
  57.    {
  58.       currentLoadedObject.setText("Starting...");
  59.       try{ Thread.sleep(500); }
  60.       catch(InterruptedException e){ e.printStackTrace(); }

  61.       setVisible(false);
  62.       dispose();
  63.    

  64.    }

  65.    public void SystemLogIn ()
  66.    {
  67.       final SystemLogIn frame = new SystemLogIn();//这个是loading完后auto去下个function的

  68.       frame.setLocationRelativeTo(null);
  69.       frame.setVisible(true);
  70.       frame.setIconImage(Toolkit.getDefaultToolkit().getImage("SystemPic/Orange-128.png"));
  71.       /*frame.addMouseListener(new MouseAdapter() {
  72.             public void mousePressed(MouseEvent e) {
  73.                 point.x = e.getX();
  74.                 point.y = e.getY();
  75.             }
  76.         });
  77.         frame.addMouseMotionListener(new MouseMotionAdapter() {
  78.             public void mouseDragged(MouseEvent e) {
  79.                 Point p = frame.getLocation();
  80.                 frame.setLocation(p.x + e.getX() - point.x,
  81.                         p.y + e.getY() - point.y);
  82.             }
  83.         });*/


  84.    }

  85.    /**
  86.    * Constructs the world
  87.    *
  88.    * @param object the object that is currently loading
  89.    * @param maxSteps indicates when the object is 100% loaded
  90.    * @param currentStep indicates how far we are at this moment
  91.    */
  92.    public synchronized void updateLoadingProgress(String object, int maxSteps, int currentStep)
  93.    {
  94.       currentLoadedObject.setText(object);
  95.       //scale
  96.       progress.setMaximum(maxSteps);
  97.       progress.setValue(currentStep);
  98.    }

  99.    public static void main(String[] args)
  100.    {
  101.       SplashScreen loader = new SplashScreen();
  102. //我放10个loop(每个以10%>20%>30%) , 你可以弄到100都可以
  103.       loader.updateLoadingProgress("Reading data...", 10, 1); goToSleep();
  104.       loader.updateLoadingProgress("Reading data...", 10, 2); goToSleep();
  105.       loader.updateLoadingProgress("Loading System...", 10, 3); goToSleep();
  106.       loader.updateLoadingProgress("Loading System...", 10, 4); goToSleep();
  107.       loader.updateLoadingProgress("Loading System...", 10, 5); goToSleep();
  108.       loader.updateLoadingProgress("Loading System...", 10, 6); goToSleep();
  109.       loader.updateLoadingProgress("Preparing...", 10, 7); goToSleep();
  110.       loader.updateLoadingProgress("Preparing...", 10, 8); goToSleep();
  111.       loader.updateLoadingProgress("Preparing...", 10, 9); goToSleep();

  112.       loader.updateLoadingProgress("Starting...", 10, 10); goToSleep();

  113.       loader.loadingFinished();
  114.       loader.SystemLogIn();
  115.    }

  116.    public static void goToSleep()
  117.    {
  118.       try{ Thread.currentThread().sleep(550);}//550 value 你要 每隔 loading%到另个loading delay ms
  119.       catch(Exception e){}   
  120.    }
  121. }
复制代码


你自己慢慢研究.....
回复

使用道具 举报

 楼主| 发表于 7-2-2010 10:25 AM | 显示全部楼层
谢谢你给提示。。。。
我会研究看看。。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 29-11-2025 07:31 AM , Processed in 0.115270 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表