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
Developer
Posts: 781
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Newbie to blackberry programming

I am new to blackberry programming, I written this code

 

package mypackage;

import net.rim.device.api.ui.UiApplication;
/**
 * This class extends the UiApplication class, providing a
 * graphical user interface.
 */
public class MyApp extends UiApplication
{
    /**
     * Entry point for application
     * @param args Command line arguments (not used)
     */ 
    public static void main(String[] args)
    {
        // Create a new instance of the application and make the currently
        // running thread the application's event dispatch thread.
        MyApp theApp = new MyApp();       
        theApp.enterEventDispatcher();
    }
    

    /**
     * Creates a new MyApp object
     */
    public MyApp()
    {        
        // Push a screen onto the UI stack for rendering.
        pushScreen(new MyScreen());
    }    
}

 

package mypackage;

import net.rim.device.api.i18n.ResourceBundle;
import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class MyScreen extends MainScreen implements HelloWorldResResource
{
	
	/*private static final long BUNDLE_ID = 0;
	private static final String BUNDLE_NAME = null;
	private static final int HELLOWORLD_TITLE = 0;
	private static final int HELLOWORLD_CONTENTSTRING = 0;
	private static final int HELLOWORLD_EXITSTRING = 0;*/
	private static ResourceBundle _resources = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
    /**
     * Creates a new MyScreen object
     */
    public MyScreen()
    {        
        // Set the displayed title of the screen       
     //   setTitle("MyTitle");
   //     add(new RichTextField(_resources.getString(HELLOWORLD_CONTENTSTRING)));
    	super(DEFAULT_MENU | DEFAULT_CLOSE);
    	//Add a field to the title region of the screen. We use a simple LabelField here.
    	//The ELLIPSIS option truncatesthe label text with “...” if the text was too
    	//long for the space available.
    	setTitle(new LabelField(_resources.getString(HELLOWORLD_TITLE), LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
    	//Add a read only text field (RichTextField) to the field portion of the screen.
    	//The RTF is focusable by default.
    	add(new RichTextField(_resources.getString(HELLOWORLD_CONTENTSTRING)));
    }
    public void close()
    {
    	Dialog.alert(_resources.getString(HELLOWORLD_EXITSTRING));
    	super.close();
    }
    public boolean keyChar(char key, int status, int time) {
	    //intercept the ESC key - exit the app on its receipt
	    boolean retval = false;
	    switch (key) {
	    case Characters.ESCAPE:
	    onClose();
	    retval = true;
	    break;
    }
	    return retval;
    }
}

 

 

I get error on HelloWorldResResource, it gives me red flag.when i click on it, it gives me 2 quick fixed. 

create interface helloworldresresource, or fix project setup.

what do i do?

plus there is red error on all of  bundle_id, bundle_name, helloworld_title, HELLOWORLD_CONTENTSTRING, 

HELLOWORLD_EXITSTRING

Developer
Posts: 781
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: Newbie to blackberry programming

modified things to make it work ike here, http://supportforums.blackberry.com/t5/Java-Development/Build-error/td-p/278366


but i be happy if someone provides me with helloworldresresource.java
Developer
Posts: 19,616
Registered: ‎07-14-2008
My Device: Not Specified

Re: Newbie to blackberry programming

Welcome to to the forum and BlackBerry Java. 

 

What you are seeing is the localization functionality available with BB apps.  More here:

 

http://supportforums.blackberry.com/t5/Java-Development/Localizing/ta-p/442783

 

and perhaps this 'lab' will help:

 

http://supportforums.blackberry.com/t5/Java-Development/Localizing-an-application/ta-p/442726