Timer in j2me canvas

Hi,
I want to implement timer in my mobile game,that will start from 5and go to 0
timer will show hours:min:sec:milisec
on screeen .
plz tell me if anybody know

Hi,
You can start a separate Thread that keeps updating the time drawn on the Canvas. You are working with which version of MIDP ?
-Priyanka

Similar Messages

  • J2ME game gui? J2ME Canvas? J2ME polish? Which is better?

    I am currently trying to build a J2ME brochure like project which is required to have rich presentation.
    JAVA is not a problem for me as I've used it for quite a long time. But since I am very new in J2ME, I am confused which technology to use, should I use j2me game gui, j2me canvas or j2me polish?
    Using j2me game gui looks good. J2me canvas looks a bit tedious to me because for a brochure like project, it will mean I will probably end up using a lot of canvas which make the application quite big. Regarding to J2ME polish, there is not many materials or examples about it. it seems that J2ME polish hasn't been used a lot and I don't know whether it's good or not.
    Anybody knows something about those three? Please give me a hand.
    Thanks.

    J2ME Polish have licensing costs associated with it:
    http://www.j2mepolish.org/licenses.html
    As for Canvas VS GameCanvas:
    GameCanvas is MIDP 2.0 and up, so depending which devices your app supports you might want to stick with Canvas. GameCanvas eases graphics flushing, but double buffering can be implemented on Canvas like so:
    Image offscreen = isDoubleBuffered () ? null :
               Image.createImage (getWidth (), getHeight ());See http://www.developer.com/java/j2me/article.php/10934_1561591_8
    section: Avoiding Flickering

  • Why can i not see the time line and canvas? Also, why am i not able to click on them either?

    I am not able to see the time line and canvas in the motion 5.  Also i am not able to click on it either

    Try selecting 'revert to original layout' in the window menu. If that doesn't help I would delete Motion preferences in ~/library/preferences/com.apple.motionapp.plist and com.apple.motionapp.LSSharedFileList.plist. You can also try deleting the layouts folder in ~/Library/Application Support//Motion. I assume that at some earlier time Motion was behaving properly. If this problem has occured when you first tried to open it after downloading then I'd reinstall it.

  • Time line and canvas missing from screen!

    Time line and canvas missing from screen!
    Help!
    Can not retreave them from Final Cut G.U.I
    G5   Mac OS X (10.4.9)  

    In the Browser, double click (aka open) ANY sequence. The timeline and canvas will reappear.
    If need be, create a new sequence.
    x

  • J2ME - Canvas - repaint

    Hi,
    I have a stupid question. As far as I know the Canvas class of J2ME doesn't have getGraphics() method. That means, that I can't get the graphic representation of the Canvas object and so I can't make changes calling the properly methods of the Graphics class.
    However, the repaint() method is the only way, to do this?
    Say, I want to draw a string to the screen when the user hits a button.
    How can I do this?
    Thanks in advance,
    holex

    Hi!! I�ve a little problem, when i used repaint() method, the canvas don�t clear.
    int k=0;
    protected void pointerPressed( int x, int y){
    if (((x>0) && (x<5)) && ((y>0)&& (y<5))){
    k=1;
    repaint();
    protected void paint(Graphics g) {
    if (k==0) {
    g.drawRect(0,0,5,5);
    if (k==1) {
    g.drawRect(1,10,10,10);
    For example, when k=0 the canvas draw a rectangle, and when k=1 the canvas draw another rectangle, but i want to erase first rectangle and it�s not occur when i used repaint() method. Please, what i need to do ?

  • J2ME Canvas and Form Objects

    I am currently in the process of converting an existing MIDP application which uses the standard high-level UI to implement menus and form objects.
    I am converting this to use the low-level UI with canvases to make the application look far more professional. There seem to be no decent tutorials realting to using the canvas to with relation to menus or user input.
    Is it possible to add the standard TextField and ChoiceGroup types into a canvas? If not, how are these implemented in existing MIDP applications that clearly use a canvas.
    Thanks for any help that you might be able to give,
    Dave

    umm abit of athread revivial but it seems that using j2me polish is more hard work than using standard j2me. This is because you need to know abit of xml and css to take full advantage of j2me polish.
    still is that the only way to create a form in a canvas?

  • How to draw  blinking coursor on J2ME canvas.?

    Hi..esperts
    I have draw a TextField on canvas. i want to draw a blinking cursor on TextField also.
    cursor will change position as characters are drawn in TextField .
    how i can do that.
    please suggest me.
    Thanks and Regards

    Don't cross post. Once is enough.
    I'm locking this thread. All responses on
    [http://forums.sun.com/thread.jspa?threadID=5345819]
    db

  • (Java ME/J2me) Canvas Vertical Scroll Problem

    Hi i have spent a couple of days creating a small canvas bassed application i hours on a glitch trying to figure out why the myscreen.translate() will not let me scoll down verticly more than two pages can anyone see the problem ?
    import javax.microedition.lcdui.*;
    public class MobileLifeList extends Canvas {
    private Font Myfont = Font.getDefaultFont();
    private int LEFTSOFTKEYCODE =  -6;
    private int RIGHTSOFTKEYCODE = -7;
    private String[] ListItems;
    private Image[] ListImages;
    private int SelectedIndex = 0;
    MobileLife midlet;
    private int Amount = 0;
    public int mywidth;
    public int myheight;
    private int PageMode;
    public int ooscounter;
    private int MyPerPage;
    public int Page = 1;
    MobileLifeList(MobileLife mymidlet,String[] items,Image[] images){
    this.midlet     = mymidlet;
    this.ListItems  = items;
    this.ListImages = images;
    protected void paint(Graphics myscreen){
    int mywidth = myscreen.getClipWidth();
    int myheight = myscreen.getClipHeight();
    myscreen.setColor(0xffffff); //WHT
    myscreen.fillRect(0,0,mywidth,myheight);
    MyPerPage = myheight/Myfont.getHeight() - 1 * Page;
    if(ooscounter>=MyPerPage){
    myscreen.translate(0,-myheight * Page);
    for(int i=0; i<=ListItems.length - 1; i++){
    if(i!=ListItems.length){
    if(SelectedIndex==i){
    myscreen.setColor(0x000000); //BLK
    } else {
    myscreen.setColor(0xFFFFFF); //BLK
    myscreen.fillRect(0,(Myfont.getHeight() + 1) * i,mywidth,Myfont.getHeight());
    if(SelectedIndex==i){
    myscreen.setColor(0xFFFFFF); //BLK
    } else {
    myscreen.setColor(0x000000); //BLK
    myscreen.drawString(ListItems,0,(Myfont.getHeight() + 1) * i, Graphics.TOP|Graphics.LEFT);
    protected void keyPressed(int keyCode) {
    String TheMobileAgent = System.getProperty("microedition.platform");
    if(TheMobileAgent.indexOf("Vodafone")>=0 || TheMobileAgent.indexOf("Panasonic/X60")>=0 || TheMobileAgent.indexOf("Sharp")>=0 || TheMobileAgent.indexOf("Panasonic/X60")>=0){
    LEFTSOFTKEYCODE = 21;
    RIGHTSOFTKEYCODE = 22;
    if(TheMobileAgent.indexOf("Motorola")>=0 || TheMobileAgent.indexOf("GX15")>=0 || TheMobileAgent.indexOf("GX25")>=0){
    LEFTSOFTKEYCODE = -21;
    RIGHTSOFTKEYCODE = -22;
    if(TheMobileAgent.indexOf("Siemens")>=0){
    LEFTSOFTKEYCODE = -1;
    RIGHTSOFTKEYCODE = -4;
    if(TheMobileAgent.indexOf("Sagem")>=0){
    LEFTSOFTKEYCODE = -7;
    RIGHTSOFTKEYCODE = -6;
    if(TheMobileAgent.indexOf("Qtek")>=0 || TheMobileAgent.indexOf("T-Mobile/MDA")>=0|| TheMobileAgent.indexOf("Verizon/XV8600")>=0 || TheMobileAgent.indexOf("Samsung/Blackjack")>=0) {
    LEFTSOFTKEYCODE = 57345;
    RIGHTSOFTKEYCODE = 57346;
    if(TheMobileAgent.indexOf("Sony-Ericsson/W910i")>=0 || TheMobileAgent.indexOf("Nokia/2630") >=0|| TheMobileAgent.indexOf("Nokia/3110_classic") >=0 || TheMobileAgent.indexOf("Nokia/3110c") >=0 || TheMobileAgent.indexOf("Nokia/3500_classic") >=0){
    LEFTSOFTKEYCODE = -3;
    RIGHTSOFTKEYCODE = -4;
    if(TheMobileAgent.indexOf("Sony-Ericsson/M")>=0|| TheMobileAgent.indexOf("Sony-Ericsson/P")>=0){     
    LEFTSOFTKEYCODE = -7;
    RIGHTSOFTKEYCODE = -6;
    if(TheMobileAgent.indexOf("Samsung/B2700")>=0){          
    LEFTSOFTKEYCODE = -5;
    RIGHTSOFTKEYCODE = -7;
    if(TheMobileAgent.indexOf("Sony-Ericsson/T303")>=0){
    LEFTSOFTKEYCODE = -6;
    RIGHTSOFTKEYCODE = -10;
    if(keyCode==LEFTSOFTKEYCODE){
    System.out.println("LEFT softkey Pressed");
    MobileLifeCanvas mListCanvas = new MobileLifeCanvas(midlet);
    Display.getDisplay(midlet).setCurrent(mListCanvas);
    if(keyCode==RIGHTSOFTKEYCODE){
    System.out.println("Right softkey Pressed");
    int act = getGameAction(keyCode);
    int PerPage = myheight/Myfont.getHeight() - 1;
    if(act==Canvas.UP){
    if(SelectedIndex > 0){
    SelectedIndex--;
    ooscounter--;
    if(act==Canvas.DOWN){
    if(SelectedIndex != ListItems.length - 1){
    SelectedIndex++;
    ooscounter++;
    System.out.println("Index:" + SelectedIndex);
    repaint();
    Thankyou,
    Rob                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    ...how can i access myscreen varible outside of my paint function?Why don't you call the variable myGraphics? myscreen is a confusing name for a variable that refers to Graphics object because there's quite a different class Screen in MIDP API.
    As for accessing Graphics from outside of paint, I am not sure if that's a good idea. If memory serves, it can change in different invocations of paint (check the Canvas class javadocs for details if you're interested).
    To have a reliable reference to Graphics, I would rather use GameCanvas (it's a subclss of Canvas with some additional features).

  • How to preview audio in real time in the canvas/timeline

    Hello there, I am new to Apple and FCP (though am an experienced Avid editor) and I have managed to get acquainted on many things already but the following is driving me nuts:
    Whenever I try to play most audio clips (sfx or music in mp3/m4a/caf format) in the timeline I get a beeping warning sound as if it was unrendered. This happens even when only playing 2 tracks of audio and nothing else. the same clip plays absolutely fine in the viewer but not in the timeline/canvas. The only clip I have tried that I don't have this issue with is the sample audio clip downloadable from the FCP help menu.
    I have made some research and believe this is due to sample rate of the source material which is not compatible with that of the sequence. In this forum someone has advised to convert all audio files to 48Khz/16bit sample rate to make things easier. Does anyone know how I can do this and/or offer general advice on this issue?
    Many thanks, Emi Polito.

    The list of audio files that FCP can work with is in the manual.... MP3, m4a's etc aren't supported. You need to transfer them to Aif's or WAV files. MP3 and M4a files are delivery formats, not editing formats. Transfering them in QuickTime or iTunes or even FCP or compressor all work to do this. But it has to be done in order for FCP to work with them.
    Jerry

  • A question about j2me Canvas?

    I want to draw a n-point ploygon, and fill some color in this ploygon, please help me, I cannot get a way to solve this problem?

    Hi , I hava download jmicropolygon_midp2-1.0.jar.
    and use
    private int[] xpoint = { 10, 100, 100, 50, 50, 30, 30, 10,10 };
    private int[] ypoint = { 10, 10, 70, 70, 40, 40, 100, 100,10 };
    g.setColor(255, 255, 255);
         g.fillRect(0, 0, getWidth(), getHeight());
         g.setColor(255,0,0);
         PolygonGraphics.drawPolygon(g,xpoint,ypoint);
    but it doesn't work.
    can you tell me how to use it?
    Thanks!!

  • J2ME Canvas grid

    I'm using that two classes to generate a table:
    http://isengard.metal.pl/TableCanvas.java
    and
    http://isengard.metal.pl/ScrollableTable.java
    (the first one uses the second)
    The table is fullscreen but I'd like it to get only 90% of screen heigth and on the top of screen I'd like to put an information about f.e. internet connection etc. The problem is because I've found this Java code illegible and don't know how to move the table to the bottom for a approximately 15 px so that on the top I'd get more place for text. Could you please give me any ideas what should I change?
    thank you

    Hi, I finally managed to get it to run on my machine (the line vec.copyInto(array); in the TableCanvas constructor threw an exception for me, apparently it doesn't like 2D arrays, so I'm suprised it works for you). But anyway, with the changes I mentioned before it works perfectly fine.
    The TableCanvas paint method:
    protected void paint(Graphics g) {
              g.setColor(0xffffff);
              g.fillRect(0, 0, getWidth(), getHeight());
              g.translate(10, 25);
              g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_PLAIN, Font.SIZE_SMALL));
              table.paint(g);
              g.translate(-10, -25);
              g.drawString("test", 60, 0, Graphics.TOP|Graphics.LEFT);
         }The ScrollableTable paint method:
    public void paint(Graphics g) {
            int cX = g.getClipX();
            int cY = g.getClipY();
            int cW = g.getClipWidth();
            int cH = g.getClipHeight();
            g.setClip(0, 0, viewportWidth, viewportHeight +10);
            g.translate(-viewportX, -viewportY);
            g.setColor(bgColor);
            g.fillRect(0, 0, width, height);
            int currentX = 0;
            int currentY = 0;
            for (int i = 0; i < rows; i++) {
                currentX = 0;
                g.setColor(borderColor);
                g.fillRect(0, currentY, width, borderWidth);
                currentY += borderWidth;
                for (int j = 0; j < cols; j++) {
                    if (i == 0) {
                        g.setColor(borderColor);
                        g.fillRect(currentX, 0, borderWidth, height);
                    if (j == currentCol && i == currentRow) {
                        g.setColor(bgFocusedColor);
                        g.fillRect(borderWidth + currentX, currentY, colWidths[j], rowHeights);
    g.setColor(foreColor);
    currentX += borderWidth;
    g.setColor(foreColor);
    for (int k = 0; k < dataRows[i][j].length; k++) {
    g.drawString(dataRows[i][j][k], padding + currentX, padding + currentY + k * (font.getHeight() + interline), Graphics.TOP | Graphics.LEFT);
    currentX += colWidths[j];
    if (i == 0) {
    g.setColor(borderColor);
    g.fillRect(currentX, 0, borderWidth, height);
    currentY += rowHeights[i];
    g.setColor(borderColor);
    g.fillRect(0, currentY, width, borderWidth);
    g.translate(viewportX, viewportY);
    g.setColor(this.foreColor);
    g.setClip(cX, cY, cW, cH);
    }I have added in g.setColor(foreColor); because otherwise the title would be drawn using the border colour.  And as I said for me it worked fine.  So I'm not sure why it is not working for you.  Try copying the above code exactly into your code and see if there is any difference, if it still does not work then you could send me your files and I'll have a look on my machine if I can get it to work.
    p.s. what emulator and IDE are you using?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Which one is better to use..Canvas or J2ME Polish

    Hello Frnds,
    I want to add background images n want to use High level GUI, So is the polish be a good option for it , or should I go for simple j2me canvas n write my own low level... GUI like construct .....or should go for Synclast 3rd party API. library......

    I've J2ME Polish on a few projects, and it can be really nice. But sometimes you just need more, you need pure Canvas flexibility. And for that (and for 90% of my projects) I use synclast. It's a canvas based container toolkit, it allows you to do a LOT with a canvas, and you can also extend it very easily to create your own widgets for the UI.
    http://synclast.com/ui_api.jsp
    don't download the release build, it's REALLY old, download the source and compile your own jar for a much more up-to-date library.

  • Problem in Timer Rescheduling

    Hello J2MEians
    I am implementing a midlet program. This is what I do...
    Make a HTTP connection to a streaming server to get 40 images at a time and then display those images on the imageitem in the midlet.
    Display of these images is done by a timer implemented by a timertask.
    The problem is sometimes HTTP connection takes time to fetch images so I had to delay the time of showing these images . Hence i want to reschedule my timer. But i'm surprised to see that there is no reschedule function for timer in J2ME.
    I implemented the same thing in applet where i use to first stop the timer by timer.stop(); then set its delay by timer.setDelay(xxxx) and then again starting it by timer.start(); . It was so easy , the next task is executed with the new delay.
    But I am unable to such kind of thing in J2ME.
    Please help in solving my problem
    Thanks in advance
    Manu

    i guess this will give u some idea:
    class mainclass extends canvas
    Timer timer = new Timer();
    Task tt= new Task();
    static long count=0;
    mainclass()
    { //scheduling afetr 1 sec
    timer.schedule(tt,0,1000);
    ///////////////////////innerclass////////////////////////////
    public class Task extends TimerTask{
    public final void run()
    count=count+1000;
    if(count>10000)
    //do your job
    }//end of run
    ///////////////////////innerclass////////////////////////////
    public void keyPressed(int keyCode)
    {//resettng
    count=0;
    }

  • Software - Canvas no longer available for the Mac

    I am looking for someone's experience - I use Canvas - a remarkable little program for drawing, word processing and almost everything including photo manipulation - ACD Systems have stopped developing and updating the program for Mac, which is a great shame (and very short sighted on ACD's part in my view) - does anyone who knows the program know of a replacement which IS being updated for the Mac? I'd really like to find a developer who is in the same space as Canvas

    Hi,
    I too am a long-time user of Canvas (3.5) and have been looking for alternatives. The problem I am finding is that Canvas has so many different tools, there is no one application that has all of the versatility of Canvas.
    I feel I need to change apps soon because I am wary that the latest OS X version of Canvas won't work much longer in OS X (as updates continue), and I need to convert my Canvas docs to something another app can read (maybe PDF?).
    I recently found an article that looks at several OS X native drawing applications, some of which I was not aware of. Perhaps one of these applications might suit as a replacement. I'm checking some of these out to see if they will suit as substitutes for the purposes I employ Canvas (mostly drawing diagrams, maps and figures).
    http://jonwhipple.com/blog/2008/05/25/drawing-conclusions/
    Cheers,
    Rob

  • Multiple canvases overlapping other canvas

    I have 3 canvases in one form. The first one will appear at the top and the other 2 will appear at the bottom. I have created a radio button in the first canvas to allow the user to have to option to choose. If the first option is choosed, the 2nd canvas will appear at the bottom of the screen(3rd canvas will be hidden) and if the 2nd option is selected, the 3rd canvas will appear same position as 2nd canvas and the 2nd canvas will be hidden.
    The "VIEWPORT_Y_POS" and ""VIEWPORT_Y_POS_ON_CANVAS" for the 1st canvas is set to ZERO while the 2nd and 3rd is set to 200.
    The "HEIGHT" property for the 1st canvas is 155 and the other 2 canvases is 480.
    During the POST_NEW_FORM and after the user selected the second option, the 1st canvas and 3rd canvas display nicely(the 2nd canvas hidden). But after the data being displayed and some of the fields in the 3rd canvas has been enabled, the 3rd canvas being overlapped by the first canvas at the top portion.
    I have double checked the coding and there is no run-time setting the canvas viewport Y position property. What was wrong with the setting? This program has been running in our production server(Application Server 9.0.2) quite some time without any problem. But, when copied to our development server(application server 9.0.4), it gave me this kind of problem.
    Is this a bug for the newer version of application server? or it's the setting problem to the canvas?

    I have tried to set the viewport of the canvas programatically during run-time, but seems like the same problem happened.
    I tried to set the viewport Y position on canvas to Zero instead of 200 and then the viewport Y position to 200 at design-time. My problem solved!
    But the question is why the 2nd canvas didn't give me this kind of problem even I have set the viewport Y position on canvas same as the 3rd canvas(the canvas will appear same position as the 3rd canvas) wherelse the 3rd canvas did?
    Another question is why when I run this form on the Apps Server 9.0.2 no problem but Apps Server 9.0.4 did?
    Thanks.
    Cheong

Maybe you are looking for

  • PO Release Strategy is not working?

    Hi, I have set the PO Release Strategy on Doc Type and Order Value and it is working fine in simulation, however, is not effective while creating STO. Have checked the assignment and it is fine. Can someone tell what is wrong? Regards.

  • No blinking cursor in textfield

    I have some textfields that I use with UITextAlignmentRight. The problem is that when I click on them to start typing the blinking cursor doesn't show wich is very confusing for the user. Then when I start typing the cursor shows. It also works when

  • Full offline + redologBackup error through DB13 with BRBACKUP VERIFY OPTION

    Dear All, I'm facing problem in backup, log is as under BR0278W Command output of '/oracle/PRD/102_64/bin/dbv file=/oracle/PRD/sapbackup/begicwjp/sr3.data12 blocksize=8192': DBVERIFY: Release 10.2.0.4.0 - Production on Thu Jul 14 21:06:43 2011 Copyri

  • Setting Timeline Markers Script in After Effects CS6

    So I'm without my desktop computer for the time being and am using a laptop in its place-which means I do not have access to a numpad. Going out to buy one is my last resort, as I don't have enough leisure time to visit a trusty electronics store. So

  • IPhoto not loading pictures

    I am trying to help a co-worker. Her Macbook has iPhoto 6. When she clicks the icon in the dock, the app starts to open and you see the iPhoto window but nothing appears in the left pane (folder tree). The black loading wheel keeps spinning and says