Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 10
Registered: ‎01-21-2009
My Device: Not Specified
Accepted Solution

Newbie to JAVA - Psuedocode needed, please!

I am hooked. I want to design my own apps.

 

I am an experienced programmer, just not in Java. 

 

My first self-appointed task is to modify the Hello World Program (of course). What I want to do is, when you choose close, a dialog appears asking to confirm ( I have successfully done this ).

 

If YES, you are brought to another screen. Thus, my road-block.

 

 

Please help me with my psuedocode, and tell me where I am going wrong. OOP is new to me btw, as I have been a PHP guy for a long time writing simple classes.

 

Here is my code (not working, but with questions embedded):

 

[code]

 

I am hooked. I want to design my own apps.

 

I am an experienced programmer, just not in Java.

 

My first self-appointed task is to modify the Hello World Program (of course). What I want to do is, when you choose close, a dialog appears asking to confirm ( I have successfully done this ).

 

If YES, you are brought to another screen. Thus, my road-block.

 

 

Please help me with my psuedocode, and tell me where I am going wrong. OOP is new to me btw, as I have been a PHP guy for a long time writing simple classes.

 

[code]

     //--------------------
    // Spevify Package
    //--------------------

    // Does this mean the "package" of files (classes)
    // should reside in the folder:
    //
    // com/rim/samples/device/multiplescreendemo  ????

    // If so, why does this root start at "com" ?
    // package com.rim.samples.device.multiplescreendemo;

    
    //---------------------
    // Import dependencies
    //---------------------
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.RichTextField;
 
// We have to extend "UiApplication" in order to:___________________  ( [Your awesome answer here!] )

public class MultipleScreenDemo extends UiApplication {

    /**
         * Entry point for MultipleScreenDemo application.
         */

        public static void main(String[] args)
        {
            // Create a new instance of the application.
            MultipleScreenDemo theApp = new MultipleScreenDemo();
        
            // To make the application enter the event thread and start processing messages,
            // we invoke the enterEventDispatcher() method.
        // --------------------------------------------
        //
        // Why are we doing this? Since this appears to be a single
        // threaded application, why do we want to mess around with
        // event listeners?
        //
        // [Your awesome answer here!]
            theApp.enterEventDispatcher();
        }


    /**
     * The constructor
    */
    public MultipleScreenDemo()
    {
        // Push the first screen
        pushScreen( new ScreenNumberOne() );
    }



    // Ok, it's obvious we need to extend MainScreen to have
    // access to its methods and properties.
    //
    // But why the keyword "final" ?
    final class ScreenNumberOne extends MainScreen{


    // Constructor
    public ScreenNumberOne(){

        // Add title
            LabelField title = new LabelField("Multiple Screens Demo" , LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
            setTitle(title);

        // Add text
            add(new RichTextField("This is screen one. There are more!" ,Field.NON_FOCUSABLE));


    }


     /**
     * Display a dialog box
     */

    public void close()
    {
        
        if ( Dialog.ask(Dialog.D_YES_NO, "Want to see another screen?") == Dialog.YES ){

        // --------------------------------------
        // HOW DO I SHOW ANOTHER SCREEN HERE?????
        // --------------------------------------

    } else {

            System.exit(0);
        
        // Super is MainScreen, right?
            super.close();

    }

    }


    }




}
 

[/code]

 

 

 

 

[/code]

 

 

 

New Developer
Posts: 38
Registered: ‎01-21-2009
My Device: Not Specified

Re: Newbie to JAVA - Psuedocode needed, please!

You can pop the current screen, or just push another one on top.
New Developer
Posts: 38
Registered: ‎01-21-2009
My Device: Not Specified

Re: Newbie to JAVA - Psuedocode needed, please!

Oh and anything after System.exit() is pointless it will never be run.
New Developer
Posts: 10
Registered: ‎01-21-2009
My Device: Not Specified

Re: Newbie to JAVA - Psuedocode needed, please!

Thanks for the reply! Wow, I am surprised you were on this board at this hour!

 

Anyways,your short answer of "You can pop the current screen, or just push another one on top." makes perfect sense, as I program in ASM (assembly) as a hobby, so I am familiar with stacks and such.

 

Thing is, all this oop is new to me.

 

I am familiar with using API's. I am familiar with classes, methods, and properties. But SUPER, and IMPLEMENT, etc are new. Also, when you instantiate a class from the MAIN method of the class, should I use super? Should I include all the dependant files again?

 

I realize these are fundamental oop Java questions that could easily be dismissed by you "go study your objects", but I am sure you are like me, and want to cut right to the chase!

 

So I am stuck.

 

I have read through the samples, and being new to Java, most are a bit advanced for day 1. I even went to Kinkos and had them print out the contact example for me (my printer got fried by lightening two days ago).

 

I am confused on the whole MainScreen thing.

 

Could someone show me a simple example of a Hello World, with a menu item "Go To Next Screen", and then have that screen show a simple message such as "Welcome to Screen 2" ??

 

I sure appreciate you taking the time to help out a newbie!

 

Regards,

 

John

New Developer
Posts: 38
Registered: ‎01-21-2009
My Device: Not Specified

Re: Newbie to JAVA - Psuedocode needed, please!

At this hour? It's only 5:30pm here, you must have over looked the fact it's daylight somewhere in the world all the time Smiley Happy

As for the need for an example, from what I've seen, I'm still struggling with a lot of the java UI concepts too, all you need to do is add another push screen and you'll have your example, also don't think the examples are always 100% acurate, they have errors in them or the documentation that comes with them can be misleading.

I wish RIM would use PHP.org as an example of how to document and make life easier for coders, php.org is brilliant when it comes to snippets for figuring out how to use one function, rather than trying to sort it all out from the entire demo you are trying to look into.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Newbie to JAVA - Psuedocode needed, please!

New Developer
Posts: 10
Registered: ‎01-21-2009
My Device: Not Specified

Re: Newbie to JAVA - Psuedocode needed, please!

Thanks, I have been studying the JDE for 3 days now, before attempting to write one line of code today.

 

Basically, I am confused on how the main class instantiates another class (another file) withing the same package.

 

The process of pushing a new screen is self explanatory. Thing is, where and when do I do that?

 

So if this was my psuedocode...

...........................................................................

1. Create Main Class

2. Instantiate NEW object of SCREEN ONE

3. Override the onclose method

4. HELP HERE (need to add a menu item "Go to next" to default menu

5. Instantiate SCREEN TWO

6. Do we need to override on close here as well?

 

Sorry to be a pain in the butt. An example would be so cool. Trust me, it's not a lack of effort on my part.

 

Thanks.

 

 

 

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Newbie to JAVA - Psuedocode needed, please!

to add menu items to your screen override makeMenu() method of your screen class.

 

also check this link:

 

http://na.blackberry.com/eng/developers/resources/developer_labs.jsp#tab_tab_jde

 

 

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Newbie to JAVA - Psuedocode needed, please!

To get solid understanding of Blackberry technology and application architecture - look closely at links I gave above.

 

Partial understanding will lead you to strange errors and unexpected application behaviour.

 

And you'll spend more time on fixing these bugs than you would spend on learning.

 

 

New Developer
Posts: 10
Registered: ‎01-21-2009
My Device: Not Specified

Re: Newbie to JAVA - Psuedocode needed, please!

What kind of forum is this? Are you serious?

 

You guys are actually suggesting I get a solid understanding of the framework's core language before attempting to dive in and write custom applications?

 

 

LOL

 

Ok, I give up. I will get a better grasp on the fundamentals of Java's OOP. Ugh... another buzword on my resume. Smiley Wink

 

Regards,

 

John