⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 password.java

📁 手机动态密码产生器
💻 JAVA
字号:
package dynamicP;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;


public class Password extends Canvas implements Runnable {
    private int width = 0;
    private int height = 0;
    private int i = 0;
    private int gameID;
    private int dia = 30;
    private int lStr;
    private int lKey;
    private int lName;
    private int hFont;
    private String password;
    private String minite;
    private String gameName;
    private CreatPassword creatPassword;
    private long second = 0;
    private boolean living = true;
    private String GameKey;
    private Font font = null;

    Password(int _gameID, String _gameKey, String _gameName) {
        gameID = _gameID;
        GameKey = _gameKey;
        gameName = _gameName;
        creatPassword = new CreatPassword(GameKey);
        password = creatPassword.getPassword();
        minite = creatPassword.getMinite();
        second = creatPassword.getSecond();
        font = Font.getDefaultFont();
        lStr = font.stringWidth("密码:36025784") + 2;
        lKey = font.stringWidth("18246913");
        lName = font.stringWidth(gameName);
        hFont = font.getHeight() + 2;
        new Thread(this).start();
    }

    protected void paint(Graphics g) {
        width = this.getWidth();
        height = this.getHeight();
        g.setColor(255, 255, 255);
        g.fillRect(0, 0, width, height);

        try {
            Image img;

            if(width > 160) {
                img = Image.createImage("/leaf.png");
            } else {
                img = Image.createImage("/leaf2.png");
            }

            g.drawImage(img, width / 2, height / 2, Graphics.HCENTER | Graphics.VCENTER);
        } catch(Exception e) {
            System.out.println("Error at creatImage" + e.getMessage());
        }

        g.drawString("密码:", (width - lStr) / 2, (height - hFont) / 2, 0);

        int posi = ((width - lStr) / 2) + font.stringWidth("密码:");
        g.drawString(gameName, (width - lName) / 2, (height - (3 * hFont)) / 2, 0);
        g.drawString(password, posi, (height - hFont) / 2, 0);
        g.setColor(255, 135, 0);
        g.drawArc(1, 1, dia, dia, 0, 360);
        g.fillArc(1, 1, dia, dia, 90, 6 * (60 - (int)(second % 60)));
    }

    public void run() {
        while(isLiving() == true) {
            try {
                Thread.sleep(800);
            } catch(Exception e) {
            }

            password = creatPassword.getPassword();
            minite = creatPassword.getMinite();
            second = creatPassword.getSecond();
            repaint();
        }
    }

    public boolean isLiving() {
        return living;
    }

    public void setLiving(boolean live) {
        living = live;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -