<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dev&#124;sushi &#187; programming</title>
	<atom:link href="http://devsushi.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://devsushi.com</link>
	<description>Discussion on Development in Several Different Flavours</description>
	<lastBuildDate>Fri, 16 Apr 2010 01:06:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Blackberry JDE API &#8211; User Interface Field Reference</title>
		<link>http://devsushi.com/2007/12/02/blackberry-jde-api-user-interface-field-reference/</link>
		<comments>http://devsushi.com/2007/12/02/blackberry-jde-api-user-interface-field-reference/#comments</comments>
		<pubDate>Sun, 02 Dec 2007 22:25:25 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[miscellaneous]]></category>
		<category><![CDATA[blackberry]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://adamhewgill.com/devsushi/2007/12/02/blackberry-jde-api-user-interface-field-reference/</guid>
		<description><![CDATA[When I first dug into programming with the RIM APIs installed with the Blackberry JDE I ran into quite a few roadblocks that took a while to circumvent. Most stemmed from my unfamiliarity with Java and the standard Java UI toolkits (Swing and AWT). After figuring out how to create and display each of the [...]]]></description>
			<content:encoded><![CDATA[<p>When I first dug into programming with the RIM APIs installed with the Blackberry JDE I ran into quite a few roadblocks that took a while to circumvent. Most stemmed from my unfamiliarity with Java and the standard Java UI toolkits (Swing and AWT). After figuring out how to create and display each of the most interesting fields I figured I might as well document them, provide screenshots, and sample application code to help others like myself.<span id="more-56"></span></p>
<p>First off for those out there only interested in the download-able code example — here you go. Simply open the FieldExample.jdw workspace in the JDE editor and click Debug -> Go.<br />
<a href="/files/FieldExamples.zip">Field Examples source code (.zip)</a></p>
<p></p>
<p>The following field objects are found in the <a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/package-summary.html">net.rim.device.api.ui.component package</a>. These objects are built-in time savers for building GUIs for Blackberry applications. One of the key benefits is that it provides your application with a consistent interface experience which guarantees users will feel right at home. Custom widgets are great and can make your application unique but each has a learning curve which could frustrate users. We&#8217;ll start with the easiest and move to the more complex.</p>
<h3>Quick Reference</h3>
<ul>
<li><a href="#nullfield">NullField</a></li>
<li><a href="#separatorfield">SeparatorField</a></li>
<li><a href="#labelfield">LabelField</a></li>
<li><a href="#textfield">TextField</a></li>
<li><a href="#richtextfield">RichTextField</a></li>
<li><a href="#editfield">EditField</a></li>
<li><a href="#passwordeditfield">PasswordEditField</a></li>
<li><a href="#bitmapfield">BitmapField</a></li>
<li><a href="#radiobuttonfield">RadioButtonField</a></li>
<li><a href="#checkboxfield">CheckboxField</a></li>
<li><a href="#objectchoicefield">ObjectChoiceField</a></li>
<li><a href="#numericchoicefield">NumericChoiceField</a></li>
<li><a href="#gaugefield">GaugeField</a></li>
<li><a href="#datefield">DateField</a></li>
<li><a href="#listfield">ListField</a></li>
<li><a href="#buttonfield">ButtonField</a></li>
</ul>
<p>Note: The API version pointed to by this article is currently v4.5.0 so all API URLs point there. Please utilize the documentation for the version installed with the development kit. It should be available in the start menu alongside the editor.</p>
<h3 id="nullfield">NullField</h3>
<p>I don&#8217;t actually have one of these in the code example since to me they seem completely pointless. I&#8217;m sure some programmers rely on them for various weird hacks but for the most part I would avoid them. They are invisible but can have focus.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/NullField.html">NullField API reference</a></p>
<h3 id="separatorfield">SeparatorField</h3>
<p>In the standard MainScreen layout it is usually necessary to use these. They are very simple to add and provide a single pixel grey horizontal line on the screen from one side to the other. The general purpose is to separate two sections of UI elements. It is possible to override the drawing behavior and change the color/shape of the line but that is a more advanced topic for a future post.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/SeparatorField.html">SeparatorField API reference</a></p>
<pre class="brush: java">add(new SeparatorField());</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/11/separatorfield.png' title='SeparatorField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/11/separatorfield.png' alt='SeparatorField screenshot' /></a></p>
<h3 id="labelfield">LabelField</h3>
<p>This element is essentially a glorified String which knows how to draw itself on the screen. As with all text based Fields you can change the drawing Font and use it as the Screen title. By default this element does not accept focus but as will all Fields you can change this by setting the Field.FOCUSABLE style.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/LabelField.html">LabelField API reference</a></p>
<pre class="brush: java">// LabelField variations

add(new LabelField("LabelField"));

add(new LabelField("LabelField 2", 0, -1, Field.FIELD_RIGHT));

LabelField lbl = new LabelField("LabelField 3", 0, -1, Field.FIELD_HCENTER);
Font fnt = this.getFont().derive(Font.BOLD | Font.ITALIC);
lbl.setFont(fnt);
add(lbl);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/11/labelfield.png' title='LabelField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/11/labelfield.png' alt='LabelField screenshot' /></a></p>
<h3 id="textfield">TextField</h3>
<p>This class seems to be abstract since it has no constructors listed in the APIs. You can create a TextField but I would avoid it since from everything I have seen it is not used. It is the parent class of RichTextField and BasicEditField which are the fields you should actually use for selectable and editable text respectively.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/TextField.html">TextField API reference</a></p>
<h3 id="richtextfield">RichTextField</h3>
<p>TextFields provide the equivalent of standard TextBox from other platforms. Each letter of the text is focusable and selectable. The RichTextField is not editable by default but can made editable by setting the Field.EDITABLE style. The major benefit of using a RichTextField over other text based fields is the configurability of the text formatting. It is quite cumbersome to setup as you can see by the following code example but is handy.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/RichTextField.html">RichTextField API reference</a></p>
<pre class="brush: java">// RichTextField variations

add(new RichTextField("RichTextField"));

String str[] = new String[] {"RichTextField:", "Value"};
int off[] = new int[] {0, str[0].length(), str[0].length() + str[1].length()};
byte attr[] = new byte[] {0, 1};
FontFamily fontfam[] = FontFamily.getFontFamilies();
Font fon[] = new Font[2];
fon[0] = fontfam[0].getFont(FontFamily.SCALABLE_FONT, 16);
fon[1] = fontfam[1].getFont(FontFamily.SCALABLE_FONT, 18);
add(new RichTextField(str[0] + str[1], off, attr, fon, RichTextField.TEXT_ALIGN_HCENTER));</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/11/richtextfield.png' title='RichTextField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/11/richtextfield.png' alt='RichTextField screenshot' /></a></p>
<h3 id="editfield">EditField</h3>
<p>Pretty much the equivalent of the LabelField but is focusable, selectable and editable. There are some mechanisms included which allow configuration of how the key presses interact with the field but overall it is very simple.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/EditField.html">EditField API reference</a></p>
<pre class="brush: java">// EditField

EditField edit = new EditField("Username: ", "");
add(edit);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/11/editfield.png' title='EditField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/11/editfield.png' alt='EditField screenshot' /></a></p>
<h3 id="passwordeditfield">PasswordEditField</h3>
<p>As you might expect this is exactly the same as the EditField but replaces keystrokes with asterisk&#8217;s. Both Fields are children of the BasicEditField class. On the Pearl there is a short delay where it shows the actual character before switching it to the asterisk (another benefit of using the built in Fields). Some of the standard features like cut/copy and the auto manipulators are disabled.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/PasswordEditField.html">PasswordEditField API reference</a></p>
<pre class="brush: java">// PasswordEditField

PasswordEditField pass = new PasswordEditField("Password: ", "");
add(pass);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/11/passwordeditfield.png' title='PasswordEditField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/11/passwordeditfield.png' alt='PasswordEditField screenshot' /></a></p>
<h3 id="bitmapfield">BitmapField</h3>
<p>The BitmapField allows you to add a Bitmap to your application. It can be aligned just like any other field with Field.FIELD_RIGHT or Field.FIELD_HCENTER and additionally can have border padding. I haven&#8217;t looked to far into positioning beyond the standard but I will get into more complex layouts in a future post. The Bitmap class can load PNG, GIF or JPEG images along with raw byte data. If you include an image in the project it is automatically added to the .cod file as a resource which can be loaded using getBitmapResource(). When targeting a resource the path begins at the root project level. I&#8217;ve made the image focusable just as an example, I belive you can also turn an image into a button.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/BitmapField.html">BitmapField API reference</a></p>
<pre class="brush: java">// BitmapField
Bitmap img = Bitmap.getBitmapResource("com/examples/img/rainbow.png");
BitmapField bf = new BitmapField(img, BitmapField.FOCUSABLE);
add(bf);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/11/bitmapfield.png' title='BitmapField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/11/bitmapfield.png' alt='BitmapField screenshot' /></a></p>
<h3 id="radiobuttonfield">RadioButtonField</h3>
<p>There are the implementation of the standard radio selection object where you put a bunch into a group and then the user can select one (and only one) of those options. If you have a fairly small set of options these can be nicer than a choice field (a.k.a. drop-down list) since a user doesn&#8217;t have to click into the list and then pick an option. You must place the RadioButtonField objects into a RadioButtonGroup or an error will occur.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/RadioButtonField.html">RadioButtonField API reference</a></p>
<pre class="brush: java">// RadioButtonField (must be part of group)
RadioButtonGroup rgrp = new RadioButtonGroup();
RadioButtonField radio = new RadioButtonField("Radio Button", rgrp, true);
RadioButtonField radio2 = new RadioButtonField("Radio 2", rgrp, false);
add(radio);
add(radio2);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/12/radiobuttonfield.png' title='RadioButtonField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/12/radiobuttonfield.png' alt='RadioButtonField screenshot' /></a></p>
<h3 id="checkboxfield">CheckboxField</h3>
<p>Again the standard implementation of a checkbox where each is individual and you can check as many as you want. It appears that you are unable to set the checkbox state to other than on or off. Other platforms generally have a third version representing half checked but it appears the user would need to extend this control to provide that functionality.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/CheckboxField.html">CheckboxField API reference</a></p>
<pre class="brush: java">// CheckboxField
CheckboxField chk = new CheckboxField("Checkbox 1", true);
CheckboxField chk2 = new CheckboxField("Checkbox 2", false);
add(chk);
add(chk2);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/12/checkboxfield.png' title='CheckboxField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/12/checkboxfield.png' alt='CheckboxField screenshot' /></a></p>
<h3 id="objectchoicefield">ObjectChoiceField</h3>
<p>The object choice field is essentially what most programmers would know as a drop-down box or list. You provide a list of objects that have the toString() method and it uses that to generate the list the user chooses from. Hitting the space key will roll through the options or the user can click to see all options at one is a list (as seen in the screenshot below). These fields are very handy when you have many options to present or when screen space is at a premium (as it is on most options pages).<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/ObjectChoiceField.html">ObjectChoiceField API reference</a></p>
<pre class="brush: java">// ObjectChoiceField
String choicestrs[] = {"Opt 1", "Opt 2", "Opt 3"};
ObjectChoiceField choice = new ObjectChoiceField("Object Choice Field: ", choicestrs, 0);
add(choice);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/12/objectchoicefield.png' title='ObjectChoiceField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/12/objectchoicefield.png' alt='ObjectChoiceField screenshot' /></a></p>
<h3 id="numericchoicefield">NumericChoiceField</h3>
<p>My only guess is that the RIM developers needed lots of choice fields that were numeric. I&#8217;m not sure why but that is the only reason to create this very limited field. It simply creates a standard choice field with numeric choices within the range given in the constructor. You can specify a start number, end number and the increment. For the most part I would recommend just using an ObjectChoiceField since it is more flexible.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/NumericChoiceField.html">NumericChoiceField</a></p>
<pre class="brush: java">// NumericChoiceField
NumericChoiceField numeric = new NumericChoiceField("Numeric Choice Field: ", 1, 10, 1, 4);
add(numeric);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/12/numericchoicefield.png' title='NumericChoiceField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/12/numericchoicefield.png' alt='NumericChoiceField screenshot' /></a></p>
<h3 id="gaugefield">GaugeField</h3>
<p>The gauge is a very handy field which allows you to show a progress bar style value selector. If the ObjectChoiceField wasn&#8217;t enough for you never to use NumericChoiceField then perhaps this field could shoulder the load. It can be a straight uneditable field or it can allow focus and edit so the user can change the value. Overall this control is great and would be handy for anybody working on game programming.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/GaugeField.html">GaugeField API reference</a></p>
<pre class="brush: java">// GaugeField
GaugeField gauge = new GaugeField("Gauge Field: ", 1, 100, 50, Field.EDITABLE | Field.FOCUSABLE);
add(gauge);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/12/gaugefield.png' title='GaugeField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/12/gaugefield.png' alt='GaugeField screenshot' /></a></p>
<h3 id="datefield">DateField</h3>
<p>I&#8217;ve never actually seen one of these in the standard suite of applications on the blackberry so it took me a bit to figure out how to use it properly. First you get down to the field and click the trackball on it. The appearance of the field will change to be the same as the screenshot below and the date, if not already set, will change to be today. You can then use the trackball to choose the date part and roll through the various dates. When finished click the trackball again to complete. Of all the fields this one has the most configuration options for what I can see. You can choose from many different date input formats and representations, overall it probably needs a full post just for itself.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/DateField.html">DateField API reference</a></p>
<pre class="brush: java">// DateField
DateField dte = new DateField("Date Field: ", Long.MIN_VALUE, DateField.DATE);
add(dte);</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/12/datefield.png' title='DateField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/12/datefield.png' alt='DateField screenshot' /></a></p>
<h3 id="listfield">ListField</h3>
<p>This element is what set me on this project in the first place. I was looking to recreate the Status screen under the Wrench icon which has a list with left and right aligned text. I wanted to make an About screen for my game that included device specs like screen size, etc and figured that would be a good way to lay it out. It certainly wasn&#8217;t easy to find out how to do it even after I discovered that ListField was the basis for it. The ListFieldCallback is more complicated than I figure is necessary but the most important part is the drawListRow method. drawText defaults to drawing left aligned text which works for the label of the field and if you add the DrawStyle.RIGHT style it will draw right aligned, voila!<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/ListField.html">ListField API reference</a></p>
<pre class="brush: java">// Listfield (must have a callback)
ListField list = new ListField();
list.setEmptyString("Nothing to see here", DrawStyle.LEFT);
list.setSize(3);
list.setCallback(new TestListCallback());
add(list);

&hellip;

final class TestListCallback implements ListFieldCallback {
    public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
        g.drawText("Testing:", 0, y, 0, w);
        g.drawText(String.valueOf(index * 111), 0, y, DrawStyle.RIGHT, w);
    }
    public Object get(ListField listField, int index) {
        return null;
    }
    public int getPreferredWidth(ListField listField) {
        return Graphics.getScreenWidth();
    }
    public int indexOfList(ListField listField, String prefix, int start) {
        return listField.indexOfList(prefix, start);
    }
}</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/12/listfield.png' title='ListField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/12/listfield.png' alt='ListField screenshot' /></a></p>
<h3 id="buttonfield">ButtonField</h3>
<p>The API had to have a button field and here it is but I don&#8217;t feel it is very useful overall. I&#8217;ve never seen one in use in the applications on the blackberry but I haven&#8217;t dug to deeply. Most applications use a ListField for their buttons instead of actual buttons. The FieldChangeListener is used to catch the click event after it is attached to the ButtonField. You can also attach the listener to any Field since the setChangeListener function is in the parent class so you could easily make a BitmapField clickable using this technique.<br />
<a href="http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/ButtonField.html">ButtonField API reference</a></p>
<pre class="brush: java">// ButtonField
ButtonField btn = new ButtonField("myButton");
btn.setChangeListener(new ButtonListener());
add(btn);

&hellip;

final class ButtonListener implements FieldChangeListener {
    public void fieldChanged(Field field, int context) {
        ButtonField btn = (ButtonField) field;
        Status.show("Button pressed: " + btn.getLabel());
    }
}</pre>
<p><a href='http://devsushi.com/wp-content/uploads/2007/12/buttonfield.png' title='ButtonField screenshot'><img src='http://devsushi.com/wp-content/uploads/2007/12/buttonfield.png' alt='ButtonField screenshot' /></a></p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://devsushi.com/2007/12/02/blackberry-jde-api-user-interface-field-reference/feed/</wfw:commentRss>
		<slash:comments>85</slash:comments>
		</item>
		<item>
		<title>Getting started with the Blackberry Java Development Environment (JDE)</title>
		<link>http://devsushi.com/2007/11/15/getting-started-with-the-blackberry-java-development-environment-jde/</link>
		<comments>http://devsushi.com/2007/11/15/getting-started-with-the-blackberry-java-development-environment-jde/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 00:15:25 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[miscellaneous]]></category>
		<category><![CDATA[blackberry]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://adamhewgill.com/devsushi/2007/11/15/getting-started-with-the-blackberry-java-development-environment-jde/</guid>
		<description><![CDATA[Recently I became frustrated with the state of free games for the Blackberry platform. BrickBreaker is really hard and choppy on the newer devices so I decided to do something about it. I also have a Blackberry Pearl just sitting at home since my recent upgrade to the Blackberry Curve. So frustration + extra device [...]]]></description>
			<content:encoded><![CDATA[<p></p>
<p>Recently I became frustrated with the state of free games for the Blackberry platform. BrickBreaker is really hard and choppy on the newer devices so I decided to do something about it. I also have a Blackberry Pearl just sitting at home since my recent upgrade to the Blackberry Curve. So frustration + extra device + time = development on the Blackberry platform. After wading through some web pages on the developer site and running into more than one snag I decided to document to process in tutorial form. I hope this helps you get starting with the Blackberry JDE. Please feel free to drop questions in the comments or to email me at <a href="mailto:ahewgill@gmail.com">ahewgill@gmail.com</a>.<span id="more-52"></span></p>
<h3>Java Required</h3>
<p>In order to develop using the Blackberry JDE you must first have installed the <a href="http://java.sun.com/javase/downloads/index.jsp">Sun Java Development Kit (JDK)</a> (more than just the JRE). This package will give you access to the java compiler which the Blackberry JDE requires.</p>
<h3>Installation</h3>
<p>The first step is to install the <a href="http://na.blackberry.com/eng/developers/downloads/jde.jsp">Blackberry Java Development Environment (JDE)</a> available on from the <a href="http://na.blackberry.com/eng/developers/">Blackberry Developer website</a>. (As of this writing the latest version is 4.5.0). You have to register for an account and verify via email in order to download the software which is very annoying. It took them 24 hours to send me the verification link so that I could sign in and begin the download. It is best to download the full JDE rather than the individual pieces in my opinion but this is up to you and your bandwidth constraints.</p>
<h3>Setting up the PATH</h3>
<p>In order to run the Java compiler, JDE requires it be in the system PATH. To do this right click on <em>My Computer</em> and click <em>Properties</em>. Now click the <em>Advanced</em> tab and then the <em>Environment Variables</em> button. In the system variables (lower) part find and select the PATH variable and then click the <em>Edit</em> button. Now at the very end of the string add <em>;C:\Program Files\Java\jdk1.x.x_yy\bin;C:\Program Files\Research In Motion\BlackBerry JDE 4.x.x\bin</em> (make sure you have the semi-colon at the front). Click <em>Ok</em>, then <em>Ok</em> again and finally one last time. You will have to check for the relevant version numbers on your own computer to fill in above.</p>
<h3>Running a few samples</h3>
<p>Once you have the JDE installed it is time to try out a few of the samples provided. First open the editor by clicking <em>Start -> Programs -> Research in Motion -> Blackberry JDE 4.x.x -> JDE</em>. Windows Firewall may ask if you want to allow JDE to access the Internet; I let it so I don&#8217;t know if it will work if blocked. Once in the editor click <em>File -> Open Workspace&#8230;</em> and browse to <em>C:\Program Files\Research in Motion\Blackberry JDE 4.x.x\samples</em> and select <em>samples.jdw</em>.</p>
<p>Let&#8217;s run the <em>HelloWorldDemo</em> sample. First thing you must do it set <em>HelloWorldDemo</em> to be the only active project. Click <em>Project -> Set Active Projects&#8230;</em> and then in the dialog that appears click <em>Clear All</em> and then check off <em>HelloWorldDemo</em> (formerly <em>com_rim_helloworld</em>) and click <em>Ok</em>. You are now ready to build and run the project. Click <em>Debug -> Go</em> to build the code and run the simulator (can take time to load so be patient).</p>
<p>The first thing you will notice is that you&#8217;re presented with a Blackberry 8300 Curve in its default configuration. Click the menu key and find <em>HelloWorldDemo</em> in the application list. Click the trackball to run it, voila! To exit the application click the menu key and then click the close option. Simple right! I encourage you to take a look through the code of the various demos at some point to become familiar with the Blackberry APIs. I have also created a <a href="http://devsushi.com/2007/12/02/blackberry-jde-api-user-interface-field-reference/">Blackberry API UI reference</a> with screenshots and sample code.</p>
<p>In the editor click <em>File -> Close Workspace</em> and then close any code windows you might have open on the right before continuing.</p>
<p><a href='http://devsushi.com/wp-content/uploads/2007/11/helloworld.png' title='HelloWorld Application in list'><img src='http://devsushi.com/wp-content/uploads/2007/11/helloworld-150x150.png' alt='HelloWorld Application in list' /></a><a href='http://devsushi.com/wp-content/uploads/2007/11/helloworld-01.png' title='HelloWorld Application running'><img src='http://devsushi.com/wp-content/uploads/2007/11/helloworld-01-150x150.png' alt='HelloWorld Application running' /></a></p>
<h3>Creating your own <em>HelloWorld</em></h3>
<p>Now that you know how to use the editor and run an application it is time to start your first program. I&#8217;m going to give you the code but the idea of this section is to learn how to create a new workspace, project, and code file. Click <em>File -> New Workspace&hellip;</em> and then give your program a name like <em>MyHelloWorld</em>. In the second box add <em>MyHelloWorld</em> to the end of the creation path leaving off the last backslash. Click <em>Ok</em> and then <em>Yes</em> to the directory creation question. You now have a new workspace in which to put your project.</p>
<p>To create the project simply click <em>Project -> Create New Project&hellip;</em> and enter the project name (eg <em>HelloWorld</em>) into the first box. This time you don&#8217;t have to mess with the directory, just click <em>Ok</em>.</p>
<p>Now it is time to add a code file to your empty project. On the left click the <em>HelloWorld</em> project in the Files tree view. Now click <em>Project -> Create New File in Project&hellip;</em> and enter a file name (eg <em>HelloWorld.java</em>) into the first box. In the second box we need to add at least one directory because Java likes to organize things into packages. Add <em>\com\sample</em> to the end of the second box and note that the automatically generated code has the line <em>package com.sample;</em>. You&#8217;ll notice this type of thing throughout the Java APIs, this is how classes are organized.</p>
<p>Now that we have a code file it is time to add some code. Replace the tiny little empty class stub (everything below the <em>package com.sample</em> line) with the follow code (I stole this directly from the <em>HelloWorld</em> sample we ran above).</p>
<pre class="brush: java">import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

/*
 * BlackBerry applications that provide a user interface
 * must extend UiApplication.
 */
public class HelloWorld extends UiApplication
{
        public static void main(String[] args)
        {
                //create a new instance of the application
                //and start the application on the event thread
                HelloWorld theApp = new HelloWorld();
                theApp.enterEventDispatcher();
        }

        public HelloWorld()
        {
                //display a new screen
                pushScreen(new HelloWorldScreen());
        }
}

//create a new screen that extends MainScreen, which provides
//default standard behavior for BlackBerry applications
final class HelloWorldScreen extends MainScreen
{
        public HelloWorldScreen()
        {
                //invoke the MainScreen constructor
                super();

                //add a title to the screen
                LabelField title = new LabelField("HelloWorld Sample",
                       LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
                setTitle(title);

                //add the text "Hello World!" to the screen
                add(new RichTextField("Hello World!"));
        }

        //override the onClose() method to display a dialog box to the user
        //with "Goodbye!" when the application is closed
        public boolean onClose()
        {
            Dialog.alert("Goodbye!");
            System.exit(0);
            return true;
        }
}
</pre>
<p>Click <em>Build -> Build</em> (or hit F7) to make sure it compiles with no errors. Any syntax errors or other messages will appear in the bottom Build window so make sure to look there before assuming everything worked. Now hit <em>Debug -> Go</em> to run the code in the Blackberry simulator.</p>
<p><a href='http://devsushi.com/wp-content/uploads/2007/11/helloworld-02.png' title='Our own HelloWorld application in list'><img src='http://devsushi.com/wp-content/uploads/2007/11/helloworld-02-150x150.png' alt='Our own HelloWorld application in list' /></a></p>
<h3>Installation on a physical device</h3>
<p>Once you have an application and have run the simulator a few times you might get the desire to install your app on an actual device. It is fairly easy to do this once you have setup the PATH variable. Open a command window by clicking <em>Start -> Run&hellip;</em> type <em>cmd</em> and hit enter. In the little black window go to the location of your application and find the .cod file. Make sure you&#8217;ve connected your device with the USB cable and then run the following command.</p>
<pre class="brush: plain">javaloader -usb load HelloWorld.cod</pre>
<p>You&#8217;re handset will go white with a spinning hour glass for a few seconds and then back to normal.  You will now see the application icon installed on the device. Congratulations you are now a Blackberry developer!</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://devsushi.com/2007/11/15/getting-started-with-the-blackberry-java-development-environment-jde/feed/</wfw:commentRss>
		<slash:comments>75</slash:comments>
		</item>
		<item>
		<title>Getting a Blackberry Curve</title>
		<link>http://devsushi.com/2007/10/19/blackberry-curve/</link>
		<comments>http://devsushi.com/2007/10/19/blackberry-curve/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 16:22:06 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[miscellaneous]]></category>
		<category><![CDATA[blackberry]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://adamhewgill.com/devsushi/?p=83</guid>
		<description><![CDATA[I just found out yesterday that I am able to upgrade my Blackberry Pearl to the Curve through the Rogers hardware upgrade plan. Work is going to pay for the upgrade which is a nice perk. A co-worker recently got the Curve and we have all been trying it out and getting hooked. Most affected [...]]]></description>
			<content:encoded><![CDATA[<p>I just found out yesterday that I am able to upgrade my Blackberry Pearl to the Curve through the Rogers hardware upgrade plan. Work is going to pay for the upgrade which is a nice perk. A co-worker recently got the Curve and we have all been trying it out and getting hooked. Most affected are those of us who have the Pearl since the Curve has a full keyboard that is decent to type on. I&#8217;ll probably review the Curve once I&#8217;ve had a week or two to play with it.</p>
<p><span id="more-83"></span></p>
<p>I&#8217;ve been considering writing a game for the Blackberry since the free ones you get from MagMic are fairly pedestrian. The other day I looked into the pay games and a vendor is selling Mahjong for ten bucks talk about a rip off. I&#8217;m not sure what type of game to make yet but I can guarantee that it will be better than Brick Breaker, I hate that game. The only game that I can stand is <a href="http://magmic.com/game/KaGlom">Ka-Glom!</a> but it becomes boring after a while. Any suggestions out there for what type of game would hold your attention? Consider the platform, 3D is out, any idea has to pretty much be moving sprite based.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://devsushi.com/2007/10/19/blackberry-curve/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

