01-23-2009 11:01 PM
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]
Solved! Go to Solution.
01-23-2009 11:56 PM
01-23-2009 11:57 PM
01-24-2009 02:11 AM
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
01-24-2009 02:38 AM
01-24-2009 02:44 AM
check the link below:
http://supportforums.blackberry.com/rim/board/mess
01-24-2009 03:23 AM
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.
01-24-2009 03:32 AM
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/
01-24-2009 03:34 AM
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.
01-24-2009 04:22 AM
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. ![]()
Regards,
John