×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    19

    Unhappy canvas help (multiple canvas)

    I have a canvas at front of my app implimenting a menu for navigation through the app to various forms, etc.
    everything works great but i really want to have the navigational commands direct to a seperate canvas for a seperate menu graphics design.

    eg.

    start app,
    goes to canvas with text pic and commands,
    commands go to various forms, etc in app,

    i want it to;

    start app,
    goes to canvas with text pic and commands,
    commands go to various (seperate canvas with different text and image and commands relating to the form, etc.)
    Huh


    PLEASE HELP ME, i have tried but am unsure how exactally

  2. #2
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: canvas help (multiple canvas)

    what exactly is the problem you are facing???
    Regards,
    Saurabh

  3. #3
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    387

    Re: canvas help (multiple canvas)

    Hi, make a command append on form, and in command action make obj of child of canvas and set it current what is the problem?
    Thanks and Regards,
    Manjul.

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: canvas help (multiple canvas)

    Switching Canvas can give you a slight flicker, so it is not advised.
    Using the Object Oritented approach, create an interface baseCanvas that extends Canvas, and define base methods for Keypress and rePaint which just calls the metods of the implimenting class.
    Make all your seperate Canvas as ScreenClass that implements this interface along with keypress & repaints for seperate flows.

    Use object passing and casting on base canvas to manage the flow from One canvas to another and your problem will be solved.

    thanks,
    ~Amitabh

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    19

    Re: canvas help (multiple canvas)

    im2amit...
    Cheers, someone was helpful finaly.. (no offence to everyone!!)
    I have tried that but when i create an interface baseCanvas that extends Canvas, the compiler can not recognise the name!! I have been teaching myself this language, so i have had no help!! I struggle alot with the simplest things!
    But i do seem to get it, though i have been stuck with this simple implimentation for a few days now!

    I'll give you my test code if it could help?... Maybe you could give me a few pointers?
    Cheers.

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: canvas help (multiple canvas)

    Hi tmf81,

    Please write more about the exact problem that you are facing, I will give you full support to implement it fast.

    Correct me if understand your problem clear: below,

    You have a multi screen application on Canvas, you dont want to write all the code to handle the events of all the screen in the keypress / event handler of your baseCanvas class and want to move it seperate class in such a way that the application code looks good and its easy to manage and does not give you any type of flicker while changing the Canvas.


    thanks,
    ~Amitabh
    Last edited by im2amit; 2009-08-18 at 11:21.

  7. #7
    Registered User
    Join Date
    Aug 2009
    Posts
    19

    Red face Re: canvas help (multiple canvas)

    Hi im2amit,
    Thanks for showing an intrest!!

    Let me clarify, i have been teaching myself this language, and only for about a month (with 4 kids under 5 screaming and wanting attention all day every day!)
    1.I have been fooling around designing myself a simple form to display "bla, bla, whatever"
    2.I then appended an image, and added a ticker.
    3.Then i decided to add a list view as well to see differences (also has selected functionality)
    4.I then added a time and date thred.
    5.Next i added multiple alerts to show pictures, (pretty much made a photo album through alerts)
    6.I implimented a guage but have no idea how to have it execute anything?..
    7.I then changed the layout to use a canvas as the start, (my menu screen with drawn text and image).
    8.I originally wanted a splash but could not figure it out, then this approach felt ok for me.
    9.Everything worked as planned in my phone, commands all working, (in which is a fair few!), pic's alerting on command.
    10.Then i thought it would be good to have it to instead of directing strait to a form or one of my alerts, i can direct it to a canvas menu like i done for the main page.
    the main reason being is because of the ammount of image alerts i have, i wanted all the commands to be at a canvas menu page like my start page. (at the moment i have about 26 commands in option menu that i would like to reduce to like i explained)
    I hope this made sense, i do apologise for my mis-guidence, i am still learning.

    Here is my code (taken text, n alerts, some commands out), sorry, i know it is messy, this is my first!!
    If you need more info or whatever, let me know.


    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.io.*;
    import java.util.*;
    import java.util.Timer;
    import java.util.TimerTask;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.List;
    import javax.microedition.midlet.MIDlet;

    public class "" extends MIDlet implements CommandListener{
    CanvasString canvas;
    private Command toggle;
    private Command "";
    private Image "";
    private StringBuffer propbuf;
    private Ticker hi;
    private Display display;
    private List list;
    private Form form;
    private Alert ualert, ealert;
    private boolean exitFlag;
    private Date date;
    private Timer tm;
    private DownloadTimer tt;
    private Gauge gaProgress;
    private DateField currentDate;
    private int index;
    String dateinstring;

    public ""() {

    hi = new Ticker("......""......");
    try{
    image = Image.createImage("/"".png");
    img = Image.createImage("/"".png");
    """"""""""""""""""""""""""
    } catch (Exception e){
    System.out.println(e.getMessage());
    }
    canvas = new CanvasString();
    }

    public void startApp() throws MIDletStateChangeException {
    Display.getDisplay(this).setCurrent(canvas);
    exitFlag = true;
    exit = new Command("Exit", Command.EXIT, 1);
    toggle = new Command("Enter", Command.SCREEN, 1);
    canvas.addCommand(toggle);
    canvas.addCommand(exit);
    canvas.setTicker(hi);
    canvas.setCommandListener(this);
    canvas.repaint();
    }

    public void pauseApp(){}

    public void destroyApp(boolean unconditional)
    throws MIDletStateChangeException
    {
    if (unconditional == false)
    {
    throw new MIDletStateChangeException();
    }
    }

    /*--------------------------------------------------
    * Process the Timer Task
    *-------------------------------------------------*/
    private class DownloadTimer extends TimerTask
    {
    public final void run()
    {
    // Is current value of gauge less than the max?
    if (gaProgress.getValue() < gaProgress.getMaxValue())
    gaProgress.setValue(gaProgress.getValue() + 1);
    }
    }

    public void commandAction(Command c, Displayable s){
    String label = c.getLabel();
    if(label.equals("Enter")){
    canvas.toggleString();
    } else if (label.equals("""")) {
    ""();

    } if (c == "") {
    ""();
    {
    }
    } if (c == List.SELECT_COMMAND) {
    String selection = list.getString(list.getSelectedIndex());
    ualert = new Alert("""", selection, null, null);
    ualert.setTimeout(Alert.FOREVER);
    ualert.setType(AlertType.INFO);
    display.setCurrent(ualert);
    {
    }
    } if (c == "") {
    ""();
    {
    }
    }if (c == exit)
    {
    try
    {
    if (exitFlag == false)
    {
    ealert = new Alert("""", "Press Exit again.",
    imge3, AlertType.INFO);

    ealert.setTimeout(Alert.FOREVER);
    ealert.setImage(imge3);
    display.setCurrent(ealert, form);
    destroyApp(false);
    }
    else
    {
    destroyApp(true);
    notifyDestroyed();
    }
    }
    catch (MIDletStateChangeException exception)
    {
    exitFlag = true;
    }
    }
    }

    public void ""(){
    hi = new Ticker("......MY WEB ACCOUNTS.....Copyright©TMFerguson2009......");
    imageItem = new ImageItem("Nice Pic",
    image, ImageItem.LAYOUT_DEFAULT, "image");
    display = Display.getDisplay(this);
    exitFlag = false;
    exit = new Command("Exit", Command.EXIT, 1);
    ""
    StringItem messages[] = new StringItem[17];
    messages[0] = new StringItem("", ", "", ", ".");
    messages[1] = new StringItem("", ", "".");
    form = new Form(""");
    form.append(imageItem);
    form.setTicker(hi);
    form.addCommand(exit);
    ""
    form.setCommandListener(this);
    display.setCurrent(form);

    }

    public void time(){
    hi = new Ticker("......Date And Time To String.....Copyright©TMFerguson2009......");
    gaProgress = new Gauge("Progress", false, 20, 1);
    tm = new Timer();
    tt = new DownloadTimer();
    tm.scheduleAtFixedRate(tt, 0, 1000);
    form = new Form("Date and Time");
    date = new Date();
    exit = new Command("Exit", Command.EXIT, 1);
    back = new Command("Back", Command.BACK, 2);
    ""
    currentDate = new DateField("", DateField.DATE_TIME);
    currentDate.setDate(date);
    dateinstring = date.toString();
    System.out.println("Date And Time Is In String Format: "+dateinstring);
    form.append("CURRENT TIME IS: ");
    index = form.append(currentDate);
    form.setTicker(hi);
    form.append(gaProgress);
    form.addCommand(exit);
    form.addCommand(main);
    form.addCommand(back);
    ""
    form.setCommandListener(this);
    display = Display.getDisplay(this);
    display.setCurrent(form);
    }

    public void myalert(){
    Alert myalert = new Alert("myalert", """,
    img, AlertType.INFO);

    myalert.setTimeout(Alert.FOREVER);
    myalert.setImage(img);
    display.setCurrent(myalert, form);
    "several others to display (similer to a photo album)"
    }

    public void ""() {
    hi = new Ticker("......""......");
    display = Display.getDisplay(this);
    exit = new Command("Exit", Command.EXIT, 1);
    ""
    list = new List("":", List.IMPLICIT);
    list.append("""", null);
    ""
    list.setTicker(hi);
    list.addCommand(exit);
    ""
    list.setCommandListener(this);
    display.setCurrent(list);
    }

    class CanvasString extends Canvas {
    boolean string = true;
    void toggleString() {
    ""();
    }

    public void paint(Graphics g) {
    int width = getWidth();
    int height = getHeight();

    g.setColor(0x000000);
    g.fillRect(0, 0, width, height);



    g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,
    Font.STYLE_ITALIC, Font.SIZE_MEDIUM));
    g.setColor(225, 255, 0);
    g.drawString("""", 0, 0, Graphics.TOP |
    Graphics.LEFT);

    g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,
    Font.STYLE_ITALIC, Font.SIZE_MEDIUM));
    g.setColor(255, 0, 128);
    g.drawString("""", 0, 15, Graphics.TOP |
    Graphics.LEFT);

    g.setFont(Font.getFont(Font.FACE_PROPORTIONAL,
    Font.STYLE_ITALIC, Font.SIZE_SMALL));
    g.setColor(51, 0, 255);
    g.drawString("""", width, height, Graphics.BOTTOM | Graphics.RIGHT);

    if(imge4 != null){
    g.drawImage(imge4, getWidth() / 2, getHeight() / 2, Graphics.HCENTER
    | Graphics.VCENTER);
    } else {
    g.setColor(0x000000);
    g.drawString("No image available", getWidth() / 2, getHeight() / 2,

    Graphics.HCENTER | Graphics.BASELINE);
    }
    }
    }
    }


    Thank you again for your intrest.

  8. #8
    Registered User
    Join Date
    Aug 2009
    Posts
    19

    Red face Re: canvas help (multiple canvas)

    sorry, i also have been trying to figure out how to make my canvas drawn image a backgroud but have had as much luck with that as the multi canvas issue

  9. #9
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    387

    Re: canvas help (multiple canvas)

    Let me clarify, i have been teaching myself this language, and only for about a month (with 4 kids under 5 screaming and wanting attention all day every day!)
    1.I have been fooling around designing myself a simple form to display "bla, bla, whatever"
    LOL and may i know who will read such a big post and copying your code and paste it building it and than running it?
    but yes, if you have average knowledge of java, you could easily crack j2me.
    Thanks and Regards,
    Manjul.

  10. #10
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: canvas help (multiple canvas)

    Quote Originally Posted by manjul_saini View Post
    LOL and may i know who will read such a big post and copying your code and paste it building it and than running it?
    but yes, if you have average knowledge of java, you could easily crack j2me.
    we are here to help those who are newbyes or in problem. I dont think so that we can LOL for them who believe that they will found the solution of their problem at FORUM. We need to help them as possible.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  11. #11
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: canvas help (multiple canvas)

    See this airtcle on wiki it might help you...
    http://wiki.forum.nokia.com/index.ph...d_applications


    thanks,
    ~Amitabh
    http://www.impetus.com/mlabs/applications.html

  12. #12
    Regular Contributor
    Join Date
    Jan 2008
    Posts
    387

    Talking Re: canvas help (multiple canvas)

    hi, i did... about the language he used :-D @jitu
    Thanks and Regards,
    Manjul.

  13. #13
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: canvas help (multiple canvas)

    Quote Originally Posted by manjul_saini View Post
    hi, i did... about the language he used :-D @jitu
    ur wish. I dont have any objection
    thanks,
    jitu_goldie..

    KEEP TRYING..

Similar Threads

  1. canvas help (multiple canvas)
    By tmf81 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 7
    Last Post: 2009-08-25, 07:58
  2. Drawing multiple images on canvas
    By anees042 in forum Symbian
    Replies: 13
    Last Post: 2008-10-17, 19:24
  3. Major problem with delegation to Canvas
    By bartekn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2003-10-08, 17:46
  4. 7650 and 3650 Canvas and FullCanvas memory
    By marcilgen in forum Mobile Java General
    Replies: 5
    Last Post: 2003-07-08, 12:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×