Results 1 to 8 of 8
Thread: show watch
- 08-29-2009, 08:57 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 11
- Rep Power
- 0
show watch
Hi i use this code to show watch but it`s not work please help me to modify it
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
/**
* @author Mahdi Farzami
*/
public class Samand extends MIDlet {
Display display;
Form form = new Form(" Samand ");
String watch;
Calendar calendar;
Timer timer = new Timer();
TimerTask timerTask = new TimerTask() {
public void run() {
watch();
}
};
public void startApp() {
display = Display.getDisplay(this);
timer.schedule(timerTask, 100, 100);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void watch() {
calendar = Calendar.getInstance();
form.delete(1);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
watch = " " + hour + " : " + minute + " : " + second + "\n";
form.append(watch);
display.setCurrent(form);
}
}
- 08-29-2009, 10:26 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 14
Don't just say "it's not work".
Explain what is happening vs what you wanted to happen.
No need to make people guess.
- 08-30-2009, 07:03 PM #3
Member
- Join Date
- Aug 2009
- Posts
- 11
- Rep Power
- 0
Hi it`s show Nothing to display , i want to show current time and it`s refresh each second
- 08-31-2009, 09:57 AM #4
Member
- Join Date
- Aug 2009
- Posts
- 11
- Rep Power
- 0
please help me how can i show watch in a form ???
- 08-31-2009, 01:28 PM #5
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 286
- Rep Power
- 13
Java Code:import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import java.util.*; /** * @author Mahdi Farzami */ public class Samand extends MIDlet { Display display; Form form = new Form(" Samand "); StringItem si=new StringItem("Time",""); String watch; Calendar calendar; Timer timer = new Timer(); TimerTask timerTask = new TimerTask() { public void run() { watch(); } }; public void startApp() { form=new Form("Watch"); form.append(si); display = Display.getDisplay(this); display.setCurrent(form); timer.schedule(timerTask, 0, 1000); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void watch() { calendar = Calendar.getInstance(); int hour = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); watch = " " + hour + " : " + minute + " : " + second + "\n"; si.setText(watch); } }
- 08-31-2009, 06:15 PM #6
Member
- Join Date
- Aug 2009
- Posts
- 11
- Rep Power
- 0
tanks my friend
- 09-05-2009, 09:59 PM #7
Member
- Join Date
- Aug 2009
- Posts
- 11
- Rep Power
- 0
Hi , how can i show clock in canvas ??? i can`t use Timer & TimerTask in canvas !!!
- 09-11-2009, 05:09 PM #8
Member
- Join Date
- Aug 2009
- Posts
- 11
- Rep Power
- 0
Hi , i use this code , it`s show time whene running midlet but it`s not change seconde or minute or hour after some time !!!
Java Code:/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import javax.microedition.lcdui.*; import java.util.*; /** * @author mahdi */ public class WatchCanvas extends Canvas implements Runnable { private static final int SECOND = 1000; private static final int MINUTE = 60 * SECOND; private volatile boolean running; /** * constructor */ public WatchCanvas() { try { setFullScreenMode(true); running = true; (new Thread(this)).start(); } catch(Exception e) { e.printStackTrace(); } } public void stop() { running = false; } /** * paint */ public void paint(Graphics g) { g.setColor(211,211,211); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(0); g.drawString(String.valueOf(Calendar.getInstance().getTime()), 100, 100, Graphics.HCENTER | Graphics.TOP); } public void run() { while (running) { try { Thread.sleep(MINUTE); } catch (InterruptedException ie) { // ignore } repaint(); } } }
Similar Threads
-
watch expression in debug mode
By bizso in forum EclipseReplies: 6Last Post: 07-08-2009, 08:07 AM -
Watch TV on PC - 12,000 TV Channels and Movies, save money Get $10 rebate.
By arturmoniswork in forum Reviews / AdvertisingReplies: 0Last Post: 12-30-2008, 05:56 AM -
[SOLVED] Folder watch Issue
By jazz2k8 in forum New To JavaReplies: 13Last Post: 07-24-2008, 05:46 AM -
netbeans 6.0 not show commpunent or show blank page
By fahimaamir in forum NetBeansReplies: 1Last Post: 01-26-2008, 06:20 AM
Bookmarks