我开发了一个简单时钟应用程序,在,Java,,,Netbeans,。现在,我想将Java 应用程序设置为壁纸。
在我的项目中有两个文件。AnimationLoopMidlet:包含startApp()函数。
AnimationLoop:更新时间并在屏幕上绘图。这是我的密码。
AnimationLoopMidlet.java
package mobileapplication1;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.*;
public class AnimationLoopMIDlet extends MIDlet{
static AnimationLoopMIDlet obj;
public AnimationLoopMIDlet()
{
AnimationLoopMIDlet.obj=this;
}
public void startApp() {
Display.getDisplay(this).setCurrent(new AnimationLoop());
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional) {
}
}AnimationLoop.java
package mobileapplication1;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.*;
import javax.microedition.lcdui.game.GameCanvas;
public class AnimationLoop extends GameCanvas implements Runnable{
boolean running;
public AnimationLoop()
{
super(false);
start();
}
void start()
{
Thread t=new Thread(this);
t.setPriority(Thread.MAX_PRIORITY);
t.start();
}
public void run()
{
running=true;
while(running)
{
update();
flushGraphics();
}
}
public void update()
{
Graphics g=getGraphics();
Date c= new Date();
String s=new String();
s=""+c;
g.setColor(0xffffff);
g.setStrokeStyle(Graphics.SOLID);
g.fillRect(0,0,240,320);
g.setColor(0x000000);
g.setFont(Font.getDefaultFont());
g.drawString("Day:"+s.substring(0,4),0,14,g.LEFT | g.TOP);
g.drawString("Month"+s.substring(4,7),0,30,g.LEFT | g.TOP);
g.drawString("Date:"+s.substring(8,10),0,50,g.LEFT | g.TOP);
g.drawString("Hour:"+s.substring(11,13),0,70,g.LEFT | g.TOP);
g.drawString("Minute:"+s.substring(14,16),0,90,g.LEFT | g.TOP);
g.drawString("Seconds:"+s.substring(17,19),0,120,g.LEFT | g.TOP);
}
}发布于 2014-03-12 06:25:30
只有少数启用JavaME的手机提供此选项。
(不过,MIDP3.0确实成为可能,但由于MIDP3.0从未见过日光,我们仍然只能使用MIDP2.1)。
您可以通过在JAD/清单中添加以下属性来使用一些索尼爱立信手机:
SEMC-StandbyApplication: Y这在索尼、爱立信、艾诺、埃尔姆和K800等设备上都适用。
http://developer.sonymobile.com/downloads/code-example-module/create-standby-midlet-for-java-platform-jp-7-phones/
https://stackoverflow.com/questions/21621813
复制相似问题