UPDATED: I am so close to getting it working, Problem description and Code

Hello to the SDN community, I am a new member and I am very inexperienced with Java. I am writing a simple photo album application that will compile and run, but not really run how I would like it to. I am sure the code is not as pretty as more experienced Java folks are used to, but I am learning.
What I would like it to do is scroll the albumName and caption Strings to the left. When those two Strings reach the left edge I would like the current photo to begin scrolling left and out of the screen while the new image simultaneously begins to scroll left into the screen from just outside the right edge towards the left edge. When the new photo begins entering the screen the new albumName and caption strings appear at the original position at HCENTER and then begin scrolling left.
The main help that I need is with the myPaint() method I think, I can't figure out how to make it work the way I just described. I can post some other versions of the method if anyone would like to see what I have tried.
Am I in need of adding more methods to the code below, or is there a way to alter this code to get the desired results? Also, if this code is written badly, please let me know (maybe suggest improvements). I am new to programming in Java and j2me. Any advice and insight will be greatly appreciated
Best Regards,
Jason
I have all kinds of versions of the myPaint() method, I can't get any that will perform the way I am trying to make it work.
The code below is very close to performing as stated. The problem with it is the next image to be displayed does not scroll in from the right as the previous image scrolls out to the left, it just pops up in the middle of the screen.
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.GameCanvas;
public class PhotoCanvas extends GameCanvas
        implements CommandListener, Runnable {
     /******* Variable declarations removed to save space/time *******/
     * constructor
    public PhotoCanvas() {
        super(true);
        exitCommand = new Command("Exit", Command.EXIT, 0);
        addCommand(exitCommand);
        setCommandListener(this);
        initPhotos();
        initParam();
        start();
    public void initPhotos() {
     /******* Loads the images into the Image[] photo array and the captions into the String[] captions array. *******/
    public void initParam() {
        if (curSlide > 2) {
            curSlide = 0;
        nextStrX = getWidth() / 2;
        nextImgX = getWidth() + (photo[curSlide].getWidth() / 2);
        if (firstRun == true) {
            strX = getWidth() / 2;
            imgX = getWidth() / 2;
        } else if (firstRun == false) {
            strX = getWidth() / 2;
            imgX = getWidth() / 2 + (photo[curSlide].getWidth());
        aniImage = false;
        nextString = false;
        change = false;
    public void start() {
        if (animation == null) {
            animation = new Thread(this);
        animation.start();
    public void run() {
        Graphics g = getGraphics();
        try {
            while (exitFlag == false) {
                changeStrX();
                if (aniImage) {
                    changeImgX();
                myPaint(g);
                Thread.sleep(30);
        } catch (Exception ex) {
            System.out.println("Error in run()");
            ex.printStackTrace();
     * paint
    public void myPaint(Graphics g) {
        //Clear Display
        g.setColor(255, 255, 255);
        g.fillRect(0, 0, getWidth(), getHeight());
        //Draw current Image according to index
        g.drawImage(photo[curSlide], imgX, getHeight() / 2,
                Graphics.VCENTER | Graphics.HCENTER);
        //Set the caption font
        Font f = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
                Font.SIZE_MEDIUM);
        g.setFont(f);
        //Draw the current caption according to the index
        g.setColor(255, 0, 0);
        g.drawString(caption[curSlide], strX, 300,
                Graphics.HCENTER | Graphics.BOTTOM);
        g.drawString(albumName, strX, 0, Graphics.HCENTER |
                Graphics.TOP);
        if (nextString == true) {
            g.drawString(albumName, nextStrX, 0, Graphics.HCENTER |
                    Graphics.TOP);
            g.drawString(caption[curSlide], nextStrX, 300, Graphics.HCENTER |
                    Graphics.BOTTOM);
        if (nextImage == true) {
            g.drawImage(photo[curSlide], imgX, getHeight() / 2,
                    Graphics.VCENTER | Graphics.HCENTER);
        flushGraphics();
    public void changeStrX() {
        strX -= 2;
        if (strX <= 0) {
            imgX -= 2;
            aniImage = true;
            nextString = true;
    public void changeImgX() {
        imgX -= 2;
         * If the left side of the image has reached
         * the left edge of the screen
        if (imgX + photo[curSlide].getWidth() / 2 <= 0) {
            nextStrX -= 2;
            curSlide += 1;
            nextImage = true;
            initParam();
}Please offer constructive criticism and suggestions as I am trying to learn.
Thanks
Edited by: newbie_dev on Oct 9, 2009 8:17 AM
Changed code

Anyone?:

Similar Messages

  • I have an iPad (original). I cannot complete the update to iOS 5.  It gets to the "backup" stage and then finds an error (-402653081). It asks if I want to continue, with a warning that "continuing will result in the loss of all contents on this iPad."

    I have an iPad (original). I cannot complete the update to iOS 5.  It gets to the "backup" stage and then finds an error (-402653081). It asks if I want to continue, with a warning that "continuing will result in the loss of all contents on this iPad." What can I do?

    Thanks Bob, I don't know why but it all of a sudden worked a few days later. It's a mystery but at least problem solved.

  • HT4623 i'm updating my iphone 3gs but i get to the activation point and it tells me the activation server is temporarily unavailable and i keep trying .i'm worried to loose some of the memo

    i'm updating my iphone 3gs but i get to the activation point and it tells me the activation server is temporarily unavailable and i keep trying .i'm worried to loose some of the memo? please advice

    That's almost always because the phone was hacked or jailbroken to unlock it.

  • After updated to ios7. my iphone 4s get warm on my iphone and i go to app store to download something that i purchased from the app store...it didn't come out anything. please tell me why or the iphone updated wrong

    after updated to ios7. my iphone 4s get warm on my iphone and i go to app store to download something that i purchased from the app store...it didn't come out anything. please tell me why or the iphone updated wrong. please tell me why it happens like this. thank you

    after updated to ios7. my iphone 4s get warm on my iphone and i go to app store to download something that i purchased from the app store...it didn't come out anything. please tell me why or the iphone updated wrong. please tell me why it happens like this. thank you

  • Will I ever get a working phone line and broadband...

    What a nightmare - nearly a week after activation data I still haven't got a working phone. Every time I call BT I get fobbed off by a indian call centre and to be honest I don't thing they know what they are doing!
    I should have know this would happen - my intial order kept getting cancelled as the exchange and my address didn't match, then they said there was working line in the property when there wasn't.
    Since my activation date I have been told;
    1) There was a probelm at the exchange
    2) there is a crossed connection
    3) outreach can't do anything because the phonenumber is for the incorrect exchange
    4) BT need to generate a new number based at the correct exchange
    I really don't know what to do now to get some progress on this - the call centre have said they will call tomorrow to tell me what will happen next.
    Can anyone offer me any advice?
    Thanks
    Claire

    Hi
    I am sorry to see you are having problems
    I suggest you contact the forum mods they should be able to get this problem sorted for you this is a link to them http://bt.custhelp.com/app/contact_email/c/4951
    They normally reply by email or phone directly to you within 3 working days they will take personal ownership of your problem until resolved and will keep you informed of progress
    They are a UK based BT specialist team who have a good record at getting problems solved
    This is a customer to customer self help forum the only BT presence here are the forum moderators
    If you want to say thanks for a helpful answer,please click on the Ratings star on the left-hand side If the reply answers your question then please mark as ’Mark as Accepted Solution’

  • Toshiba 3D TV conked off after automatic Software Update!! Need help to get it working like before

    Hi there,
    I' Using the Toshiba 46TL963G TV since 5 monts, recetly i asked for the **bleep** new software update and I let it install (ofcourse its connected via ethernet cable). After instalment the TV restarted automatically and everything was fine. I could watch TV well and I turned it OFF. and later Next morning When I turned On, it doesn't function anymore!!
    How Crap is this TV.. It does the automatic software update and it conks off itself!!!
     and the most annoying thing is that I went to this website "http://support.toshiba.com/" to get the support for this TV and when I entered the 8 charachter moderl of my TV , it say, wrong entry. WTF!!!! You dont clain your own product as yours??
    Please help me how can I get my TV working fine as before, else I really have to start working on creating a blog "Reason Why one SHOULD not buy TV from TOSHIBA"
    - Many thanks
    Aravind

    Peter, You _know_ that the firmware update crashes the TV. There have been enough reports of this online, and so much of it here on this forum that you cannot have missed it. Users need to resort to auto-flashing the firmware with files that are not publicly available from your site. Could you not at least remove the offending firmware from the list of things the television can automatically download? Aravind, you might try contacting the toshiba support to get them to send you the correct file to put on an USB device to force the TV to launch the update once plugged. Roaming the forums, it seems like this file should be something like "46TL963G_******_INIT_CLEAR.bin". Kellindil

  • Just upgraded to iPhone 5 and when i am buying or updating Apps via iTunes i keep getting asked for different user and login details 1) my old mobileme login and then 20 my new iCloud login - how do I get this resolved so that i have just one login and pa

    Just upgraded to iPhone 5 - now when i am asked to upgrade and App it askes me alternatley for my old mobile me acconut details and then the new iCloud user name and password - how do i change deatils to just one login?

    You cannot merge apple id's. remember that before creating any new ones in the future.
    You have two choices. Live with it, or repurchase the apps under the id you intend to keep using.

  • I never get make work messages, facetime and iCloud with my Apple ID. why an how?

    First all I'm sorry my English please.
    I have a MacBook Pro 2009 with Mavericks updated.
    I want to use Messages, iCloud, Facetime...but once I type my Apple Id (I use it without problems in appStore) Facetime and Messages stay for a long time trying to work but never connect so they don't work.
    I really don't know what can I do to use these programs so could someone help me, please?
    iCloud say : Account limit reached
    Messages: don't say anything, just never complete once I press "Sign in" and keeps loading.
    Facetime : Could not sign in. Please check your network connection and try again.
    I never have seen iCloud, Messages and Facetime even iChat work because always happen this problem.
    Thanks..

    Hummm,
    The inclusion of  "iChat never worked"  as well as the current version does point to other problems
    This may be whether your Mac Firewall is On and is allowing these apps and their supports apps (IMAgent in Lion Onwards and iChat agent in iChat 5/Snow Leopard and earlier.
    It could also be your Router and any ports it needs opening and whether it too has a firewall that also needs the ports opening.
    http://support.apple.com/kb/HT4245  Lists the iOS devices port needs for FaceTime and Messages.
    They would be no different on a Mac.
    http://support.apple.com/kb/HT1507  Details the ports iChat 4 and earlier used.
    These are reduced now. AIM logs in on port 443 (rather than 5190), port 5060 is not longer used.
    A/V chats are on one port reducing the "group of 20" (16384-16403) to just 10 (16393-16402)
    iChat would have been AIM, Jabber or in iChat 6 Yahoo as well and not iMessages
    iMessages needs both port 443 than 5223 to Login  (Jabber uses port 5223 as well and this maybe where your iChat attempts and the current ones cross over.
    10:57 pm      Friday; February 28, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Has ANYONE managed to get OS2 working with WiFi and bridge?

    I've scoured the forum, and tried everything - right now, its a cute, flat paperweight.

    I have!
    If you are having the same problems as me, on update, I had no wifi connections at all - didn't find a single one, despite the area being overrun with wifi networks.
    Connect your paperweight, I mean, Playbook, to the Desktop Software, take a backup, then do a security swipe and reset the whole thing.
    With mine, as soon as it came back on after the swipe the wifi was working correctly.
    I re-connected it to the Desktop Software, accepted any updates it was offering, then restored my backup from this morning.
    Hey presto!  A fully functioning Playbook!
    Good luck!

  • The audio player doesnt play in firefox get "javascript:;" - works in google and explorer - where is support???

    i am using a music player from a theme template (elegant themes) - it works on google chrome, explorer but not firefox - in firefox i get the word "javascript:;" each time i press play and it doesn't work...i tried turning off all plugins..still doesn't work...please help

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How do you get iPad working if you forget code

    I forgot the code to my ipad and cannot sync to original computer. Is there a way to get it on again?

    If you Find My iPad enabled on it then you might be able to remotely wipe it via http://icloud.com
    Otherwise you will need to connect it to a computer's iTunes and reset the iPad.
    Forgotten passcode : http://support.apple.com/kb/HT1212
    Have you been backing up to icloud so that you can then restore to that backup ? If not, and if you don't have a copy of your downloads on a computrer, then you might be able to redownload some/all of your past purchases via the Purchased tabs in the store apps.

  • Can't get Firefox working

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/891364]]</blockquote>
    I can't seem to get Firefox working, along with Firefox IE is also not working. I have to use chrome. Although I have to get Firefox working. Firefox and IE won't open any webpage

    A possible cause is security software (firewall) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.com/kb/Server+not+found
    *https://support.mozilla.com/kb/Firewalls
    Do a malware check with some malware scanning programs on the Windows computer.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br /><br />
    *http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    *http://www.superantispyware.com/ - SuperAntispyware
    *http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    *http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    *http://www.lavasoft.com/products/ad_aware_free.php - Ad-Aware Free
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Got a used iPad from a friend and reset it with the password and now it wants to be connected to iTunes but I have no computer so how do I get it working???

    How do I get iPad working without itunes and a computer when it wants to be hooked to iTunes after a reset?

    rotes9 wrote:
    How do I get iPad working without itunes and a computer when it wants to be hooked to iTunes after a reset?
    Use a friends computer.  IF the ipad is telling you to connect to iTunes that is what you need to do, there is no bypassing this.

  • No matter what I try I can't get Java working on Lion

    I have been trying since day 1 to get Java working on Lion and nothing works. I've been searching forums and doing everything reccommended with absolutely no results. I have tried it on Safari, Firefox and Chrome. None of which worked. I have reinstalled java numerous times. I have played with the java preferences such as swapping the 32-bit & 64-bit oder on main tab as well as selecting "Enable-run with protections, No warning" on the advanced tab. No matter what I do, it just refuses to work. Does anyone have any insight into what I can do to get this up and running?
    Thanks
    Phillip

    Okay. If iTunes is endlessly saying "Accessing iTunes Store", let's first try the following document:
    Apple software on Windows: May see performance issues and blank iTunes Store
    (If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.)

  • Error code: MobileMe Services has encountered a problem and needs to close - I get this message everytime i open Outlook and it slows down opening?  This problem started when itunes updated

    Error code: MobileMe Services has encountered a problem and needs to close
    I get this mesage everytime i open Outlook and it slows down opening. This problem started when itunes updated. What do I do to solve this?

    Hi turingtest2 (you pass, BTW):  Thanks for the speedy reply.  MobileMe doesn't appear in the list of programs which can be uninstalled.  I tried the link you suggest: http://support.microsoft.com/mats/Program_Install_and_Uninstall but when I tried to "Run Now", I get the error message:  " Troubleshooting cannot continue because an error has occurred... etc.... [code 80072F8F]"  So googled this error & found a tool called (80072f8f) Repair Tool   -  I'm leery to download yet more stuff from non-microsoft sites -- any recommendations?

Maybe you are looking for