<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-801021240915912006</id><updated>2011-11-28T01:51:53.962+01:00</updated><category term='SplashScreen'/><category term='debug'/><category term='J2Me'/><category term='on-device'/><category term='java'/><category term='WTK'/><category term='Eclipse'/><category term='log'/><category term='Mac'/><category term='ZappOne.tv Tutorial FAQ'/><category term='Tutorial'/><category term='Gear'/><category term='OSX'/><category term='Event'/><category term='Widgets'/><category term='Form'/><category term='EventManager'/><category term='Ogre3D'/><title type='text'>The Apes Corner</title><subtitle type='html'>Tutorials, how-to, and life experiences from DigitalApes developers.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://digitalapes.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://digitalapes.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Paolo</name><uri>http://www.blogger.com/profile/16172678310067045282</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1NfXJ8vxGrs/R4AzHLSp1yI/AAAAAAAAABI/QMrDFb_9KBw/S220/rastapal.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-801021240915912006.post-5855303445809513583</id><published>2009-02-03T15:51:00.010+01:00</published><updated>2009-02-08T14:53:17.818+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WTK'/><category scheme='http://www.blogger.com/atom/ns#' term='J2Me'/><category scheme='http://www.blogger.com/atom/ns#' term='Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='SplashScreen'/><category scheme='http://www.blogger.com/atom/ns#' term='Gear'/><category scheme='http://www.blogger.com/atom/ns#' term='Widgets'/><title type='text'>Developing mobile applications using Gear episode 5: Display a splash screen</title><content type='html'>During the first phase of a MIDlet's life, it's common to find a lot of setup code used to initialize resources, data structures, user interfaces and anything else will be required. In this case, it's a best practice to display a splash screen to inform the user that the application is not frozen but is starting up. With the release of version 1.2.0 of Gear Java Mobile Framework, we've included a consistent yet customizable implementation for this feature.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-size:180%;"&gt;1 How to achieve it ?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;To properly setup Gear SplashScreen, all you have to do is create some keys inside the JAD file:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;"SplashScreenImage:" -&gt; contains a string with the path to the desired background image&lt;br /&gt;&lt;/li&gt;&lt;li&gt;"SplashScreenText:" -&gt; contains a string with the desired text&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;If you are developing your application inside Eclipse with MTJ plugin (former EclipseME), you can easily achieve this by opening the Application Descriptor tab and "Add" the two key-value entries.&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="http://4.bp.blogspot.com/_95zInHFbLAg/SYhw7JY9DAI/AAAAAAAAACA/3nyBulP0OTk/s400/keys.PNG" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 118px;" alt="" id="BLOGGER_PHOTO_ID_5298609123036564482" border="0" /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If your development environment is a different one, you have to manually insert those keys inside your application's JAD file.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="http://1.bp.blogspot.com/_95zInHFbLAg/SYhxG05vs1I/AAAAAAAAACI/Szuvs2isUNU/s400/keys2.PNG" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 361px; height: 100px;" alt="" id="BLOGGER_PHOTO_ID_5298609323695387474" border="0" /&gt;&lt;/div&gt;&lt;div&gt;As long as there is at least one of the two keys inside your JAD file, Gear will display the SplashScreen, so if you don't want it, simply don't specify anything.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:180%;"&gt;2 Writing initialization code&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Now that the SplashScreen is enabled, all you have to do is to override a single method inside your MIDlet &lt;/div&gt;&lt;pre&gt;protected void onMidletInitializationComplete()&lt;br /&gt;&lt;/pre&gt;&lt;div&gt;and fill it with your custom initializzation logic. We encourage users to follow this practice to put setup code inside this function rather than into the GearMIDlet constructor so they can take advantage from SplashScreen avoiding user interface freezes.&lt;/div&gt;&lt;div&gt;Here is an example of a possible implementation:&lt;/div&gt;&lt;pre&gt;protected void onMidletInitializationComplete() {&lt;br /&gt;// Call some custom initializzation methods&lt;br /&gt;initDatabase();&lt;br /&gt;doSomeHeavyDutyWork();&lt;br /&gt;  initUserInterface();&lt;br /&gt;// ... and finally show the user the UI&lt;br /&gt;EventManager.getInstance().enqueueEvent(new DisplayWidget(this, LoginForm.class));&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-size:180%;"&gt;3 The result&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Gear's SplashScreen can display an image background, text and comes with an animated throbber centered vertically and anchored to the bottom of the screen. This is a possible result obtained with it:&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_95zInHFbLAg/SYh0rPklNYI/AAAAAAAAACQ/Rz2-wT_qudk/s1600-h/splash.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 276px; height: 400px;" src="http://4.bp.blogspot.com/_95zInHFbLAg/SYh0rPklNYI/AAAAAAAAACQ/Rz2-wT_qudk/s400/splash.PNG" alt="" id="BLOGGER_PHOTO_ID_5298613247864550786" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;Unfortunately this screen-shot is just a static image and you can't actually see the spinning animation of the throbber.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/801021240915912006-5855303445809513583?l=digitalapes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://digitalapes.blogspot.com/feeds/5855303445809513583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=801021240915912006&amp;postID=5855303445809513583' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/5855303445809513583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/5855303445809513583'/><link rel='alternate' type='text/html' href='http://digitalapes.blogspot.com/2009/02/display-splash-screen-on-gear.html' title='Developing mobile applications using Gear episode 5: Display a splash screen'/><author><name>Ste</name><uri>http://www.blogger.com/profile/06788236330368835587</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_95zInHFbLAg/SYhw7JY9DAI/AAAAAAAAACA/3nyBulP0OTk/s72-c/keys.PNG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-801021240915912006.post-6097315866791709876</id><published>2009-02-02T10:26:00.014+01:00</published><updated>2009-02-02T16:52:31.062+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='J2Me'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='on-device'/><category scheme='http://www.blogger.com/atom/ns#' term='log'/><category scheme='http://www.blogger.com/atom/ns#' term='debug'/><category scheme='http://www.blogger.com/atom/ns#' term='Gear'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><title type='text'>Developing mobile applications using Gear episode 4: On-device debug</title><content type='html'>Last version of &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=234344"&gt;Gear framework (1.2)&lt;/a&gt; introduced a new message logging system.&lt;br /&gt;By using Gear logger it's now possible to trace various types of application messages and print out the resulting log on different output types, including device screen.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;1. New library debug release&lt;br /&gt;&lt;/span&gt;Introducing a logging system in the framework brought a big advantage but leaded also to a performance issue: most of the times the whole logger is useless in the final release of an application and the operations required by the logger to do its work may "steal" precious resources to the rest of the application.&lt;br /&gt;So, starting from version 1.2 we dediced to make two separate releases of the library's JAR: one including the whole logging sub-system and one including only the method stubs.&lt;br /&gt;The two packages are fully compatible, so you can switch anytime between them.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;2. Logger structure and usage&lt;br /&gt;&lt;/span&gt;The base class of the logging sub-system is Logger. Through this class it is possible to select what kind of messages have to be printed&lt;br /&gt;&lt;pre&gt;// Tells the Logger to print gear system level messages&lt;br /&gt;Logger.logSystemMessages(true);&lt;br /&gt;&lt;/pre&gt;and select the desired output destination&lt;br /&gt;&lt;pre&gt;// Tells the Logger to print his messages on to the Standart Output&lt;br /&gt;Logger.out = new StandardOutput();&lt;br /&gt;&lt;/pre&gt;By default the Logger class is created with NullLogger set as output destination (it doesn't print any message) and logs just user messages (printed by the programmer inside code) and exceptions (any exception printed within code using Logger.out.println(Exception)).&lt;br /&gt;Gear provides three implementation for LogOutput:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;NullLogger : every method is implemented with an empty body and thus no message will be traced.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;StandardOutput : prints messages on the Standard Output, usually the development console.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;GWConsole : displays a graphic console directly on device's screen and prints messages on it.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;For example, to print a log message on device's screen, the following code should be used:&lt;br /&gt;&lt;pre&gt;Logger.out = new GWConsole();&lt;br /&gt;Logger.logUserMessages(true);&lt;br /&gt;Logger.out.println("Log message");&lt;br /&gt;&lt;/pre&gt;Note that the second line is not compulsory since user messages logging is enabled by default.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;3. Make your own LogOutput&lt;br /&gt;&lt;/span&gt;If you have special logging requirements, such as redirecting logs to a remote server, you can write your own custom output target and then use it with Gear's Logger. The class must implement LogOutput interface and should extend the InternalLogger abstract class.&lt;br /&gt;The class structure should look like this one:&lt;br /&gt;&lt;pre&gt;public class RemoteLogger implements LogOutput&lt;br /&gt;                  extends InternalLogger {&lt;br /&gt;&lt;br /&gt;// Instance fields ...&lt;br /&gt;// ...&lt;br /&gt;&lt;br /&gt;public void println(int logLine) {&lt;br /&gt; if (Logger.isUserMessagsLogged()){&lt;br /&gt;           // Network communication ...&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void println(double logLine) {&lt;br /&gt; if (Logger.isUserMessagsLogged()){&lt;br /&gt;           // Network communication ...&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void println(String logLine) {&lt;br /&gt; if (Logger.isUserMessagsLogged()){&lt;br /&gt;           // Network communication ...&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void println(Exception logLine, Object sender) {&lt;br /&gt; if (Logger.isExceptionsLogged()){&lt;br /&gt;           // Network communication ...&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void println(Exception logLine,&lt;br /&gt;           Object sender, String methodName) {&lt;br /&gt; if (Logger.isExceptionsLogged()){&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void printSystemMessage(String message) {&lt;br /&gt; if (Logger.isSystemMessagsLogged()){&lt;br /&gt;           // Network communication ...&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;4. Conclusions&lt;br /&gt;&lt;/span&gt;Gear's logging system allows keeping track of application activities for debug, statistical or any other purpose, it provides a simple system to filter messages and handle different output targets. In addition to this, the overhead introduced by the Logger system can be stripped without changing any line of code, just by switching from Gear's debug JAR to the release one. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/801021240915912006-6097315866791709876?l=digitalapes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://digitalapes.blogspot.com/feeds/6097315866791709876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=801021240915912006&amp;postID=6097315866791709876' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/6097315866791709876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/6097315866791709876'/><link rel='alternate' type='text/html' href='http://digitalapes.blogspot.com/2009/02/developing-mobile-applications-using.html' title='Developing mobile applications using Gear episode 4: On-device debug'/><author><name>Paolo</name><uri>http://www.blogger.com/profile/16172678310067045282</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1NfXJ8vxGrs/R4AzHLSp1yI/AAAAAAAAABI/QMrDFb_9KBw/S220/rastapal.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-801021240915912006.post-3946793394265055086</id><published>2009-01-29T10:59:00.018+01:00</published><updated>2009-02-08T14:53:54.580+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WTK'/><category scheme='http://www.blogger.com/atom/ns#' term='Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='Event'/><category scheme='http://www.blogger.com/atom/ns#' term='Gear'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='EventManager'/><title type='text'>Developing mobile applications using Gear episode 7: Work with EventManager and async messages</title><content type='html'>With this tutorial we're going to learn the basic concepts behind EventManager class and how we can send asynchronous messages across our Midlet with &lt;a href="https://sourceforge.net/projects/gearjmf/"&gt;Gear Java Mobile Framework&lt;/a&gt;. To better understand this guide, we suggest you to read at least &lt;a href="http://digitalapes.blogspot.com/2008/07/developing-mobile-applications-using.html"&gt;this&lt;/a&gt; post about configuring Eclipse and to download Gear's latest release (&lt;a href="https://sourceforge.net/project/showfiles.php?group_id=234344"&gt;1.2.0&lt;/a&gt;).&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-large;"&gt;1.0 EventManager&lt;/span&gt;:&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Working with Gear in most cases requires to use EventManager class to dispatch asynchronous messages to other Objects within your MIDlet. It's implemented following the Singleton pattern so there will be only one instance of it during execution time and you can reference it wherever you want inside your code via public method getInstance(). Let's go on how to use this class and its methods.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;1.1 Events&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Every message you want to be forwarded through EventManager must derive from the abstract class Event. It contains the basic structure and methods to keep track of the sending Object and category. Here's an example:&lt;/div&gt;&lt;pre&gt;public class ConnectionClosed extends Event {&lt;br /&gt;// Public constructor with empty EventArgs object&lt;br /&gt;public HideMidlet(Object sender){&lt;br /&gt; super(sender);&lt;br /&gt;}&lt;br /&gt;// Public constructor with user defined EventArgs&lt;br /&gt;public HideMidlet(Object sender, ConnectionClosedEventArgs eventArgs){&lt;br /&gt;        super(sender, eventArgs);&lt;br /&gt;// Override of getCagegory method to return the desired type&lt;br /&gt;public Category getCategory() {&lt;br /&gt; return Category.APPLICATION;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;1.2 EventArg&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As you noticed in last example, you can assign some custom defined arguments to an event to pass on additional data to the receiving Object. To achieve this, you have to extend EventArg class and implement your own private fields along with proper getter and setters. Here's an example:&lt;/div&gt;&lt;pre&gt;public class ConnectionClosedEventArgs extends EventArg {&lt;br /&gt;private ConnectionStatus connectionStatus;&lt;br /&gt;&lt;br /&gt;   public ConnectionClosedEventArgs(ConnectionStatus connectionStatus) {&lt;br /&gt; super();&lt;br /&gt; this.connectionStatus = connectionStatus;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public ConnectionStatus getConnectionStatus() {&lt;br /&gt; return connectionStatus;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where ConnectionStatus is a user defined class containing additional information about the reason for connection termination.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;1.3 Dispatch events&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This task is pretty simple. Suppose Object A wants to send some message to Object B (we'll see on the next poit how B will actually receive it). All it have to do is to obtain a reference to EventManager and enqueue the desired message, wrapped inside an Event object.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;EventManager.getInstance().enqueueEvent(new MyEvent(this))&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;That's it. In this particular case, we're sending a MyEvnet (which derives from Event class) and we don't have to care about anything else. EventManager will internally manage our request and dispatch it. Notice we passed "this" parameter to the Event constructor to allow a reference of the original sender to be kept.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;1.4 Register and receive Events&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to receive an Event, an Object must first implement an interface named EventHost and thus it's only method&lt;/div&gt;&lt;div&gt;&lt;pre&gt;public void notify(Event event);&lt;/pre&gt;and secondly register itself to EventManager by calling&lt;/div&gt;&lt;div&gt;&lt;pre&gt;public void registerHost(EventHost host, Event.Category category)&lt;/pre&gt;where the second argument is one of the categories mentioned before. A class that is registered to at least one Event.Category will be notified of incoming messages. Whenever you need to unregister an Object from EventManager you can call&lt;pre&gt;public void removeHost(EventHost host)&lt;br /&gt;&lt;/pre&gt;to totally remove it from the queue or&lt;br /&gt;&lt;pre&gt;public void removeHost(EventHost host, Event.Category category)&lt;br /&gt;&lt;/pre&gt;if you just want to stop being notified for a specific category of events.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;1.5 Events and GearMIDlet&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;By default, GearMidlet register itself to APPLICATION and GRAPHICS categories inside its base constructor, but if you need to be aware of more Events or less you can register/unregister from EventManager as seen in previous sections.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-large;"&gt;2.0 Putting it all together&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With all the concepts from previous section, we can now create a GearMidlet with full support for asynchronous messages:&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class GearTouchDemo extends GearMidlet {&lt;br /&gt;&lt;br /&gt;protected boolean onDestroy() {&lt;br /&gt; return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void onPause() {&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void onStart() throws MIDletStateChangeException {&lt;br /&gt;              // Enqueue a request to display MainMenu user interface&lt;br /&gt; EventManager.getInstance().enqueueEvent(new DisplayWidget(this, MainMenu.class));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class MainMenu extends GWGrid {&lt;br /&gt;public MainMenu(){&lt;br /&gt; super(2,2);&lt;br /&gt; addItem("Photo browser", "/icons/c1.png");&lt;br /&gt; addItem("Drops", "/icons/c2.png");&lt;br /&gt; addItem("None", "/icons/c3.png");&lt;br /&gt; addItem("Nothing here", "/icons/c4.png");&lt;br /&gt; setTitle("Main menu");&lt;br /&gt; addCommand(CommonCommands.SELECT);&lt;br /&gt; addCommand(CommonCommands.EXIT);&lt;br /&gt; setCommandListener(new MainMenuCommandListener());&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void itemClicked(ImageItem clickedItem) {&lt;br /&gt; if (commandListener != null){&lt;br /&gt;  commandListener.commandAction(CommonCommands.SELECT, this);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void selectElement(){&lt;br /&gt; switch (getSelectedIndex()){&lt;br /&gt; case 0:&lt;br /&gt;                      // Enqueue a request to display MainMenu user interface&lt;br /&gt;  EventManager.getInstance().enqueueEvent(new DisplayWidget(this, PhotoBrowser.class));&lt;br /&gt;  break;&lt;br /&gt; case 1:&lt;br /&gt;                      // Enqueue a request to terminate the MIDlet.&lt;br /&gt;  EventManager.getInstance().enqueueEvent(new QuitEvent(this));&lt;br /&gt;  break;&lt;br /&gt; default:&lt;br /&gt;  displayAlert("Function not implemented");&lt;br /&gt;  break;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/801021240915912006-3946793394265055086?l=digitalapes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='https://sourceforge.net/projects/gearjmf/' title='Developing mobile applications using Gear episode 7: Work with EventManager and async messages'/><link rel='replies' type='application/atom+xml' href='http://digitalapes.blogspot.com/feeds/3946793394265055086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=801021240915912006&amp;postID=3946793394265055086' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/3946793394265055086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/3946793394265055086'/><link rel='alternate' type='text/html' href='http://digitalapes.blogspot.com/2009/01/work-with-gear-eventmanager-and-async.html' title='Developing mobile applications using Gear episode 7: Work with EventManager and async messages'/><author><name>Ste</name><uri>http://www.blogger.com/profile/06788236330368835587</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-801021240915912006.post-5526161166059970581</id><published>2009-01-20T12:40:00.020+01:00</published><updated>2009-01-21T23:31:50.382+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='OSX'/><category scheme='http://www.blogger.com/atom/ns#' term='Ogre3D'/><category scheme='http://www.blogger.com/atom/ns#' term='Mac'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><title type='text'>Develop Ogre3D applications using Eclipse on Mac OS X</title><content type='html'>This tutorial will lead you trough all the steps required to configure Eclipse for Ogre 3D applications development on Mac OS X.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Requirements&lt;/span&gt;&lt;br /&gt;To perform the tasks described in this tutorial it is necessary for you to setup a basic development system including:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://developer.apple.com/technology/xcode.html"&gt;Developer tools for Mac OSX&lt;/a&gt; (XCode 3.1.2 or later)&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.eclipse.org/downloads/"&gt;Eclipse&lt;/a&gt; (3.4 or later) and Eclipse CDT plugin (downloadable from eclipse official update site) or directly Eclipse for C/C++ Developers version&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.ogre3d.org/index.php?option=com_content&amp;amp;task=view&amp;amp;id=411&amp;amp;Itemid=131"&gt;Ogre pre built SDK&lt;/a&gt; (1.6 or later)&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:180%;"&gt;Application creation&lt;/span&gt;&lt;br /&gt;To create your first application start Eclipse and select &lt;span style="font-style: italic;"&gt;New&lt;/span&gt; -&gt; &lt;span style="font-style: italic;"&gt;C++ Project&lt;/span&gt; from the &lt;span style="font-style: italic;"&gt;File&lt;/span&gt; menu.&lt;br /&gt;Now select &lt;span style="font-style: italic;"&gt;Hello World C++ Project&lt;/span&gt; and give it a name (let's say MyFristOgreApp).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Application configuration&lt;/span&gt;&lt;br /&gt;The application is now created, but is not connected in any way to Ogre, thus any ogre specific code, if compiled, would give compilation, link and run-time errors.&lt;br /&gt;To solve this problem you have to include the Ogre framework in your application, and make the project aware of the Ogre and Carbon frameworks position.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Right-click on your project name in the &lt;span style="font-style: italic;"&gt;Project Explorer&lt;/span&gt; and select &lt;span style="font-style: italic;"&gt;Import&lt;/span&gt;, then select import from &lt;span style="font-style: italic;"&gt;File System&lt;/span&gt;.&lt;br /&gt;Browse to the &lt;span style="font-style: italic;"&gt;Dependencies&lt;/span&gt; directory of the OgreSDK folder, select the subfolders and then import it in the &lt;span style="font-style: italic;"&gt;Frameworks &lt;/span&gt;subdir for your project.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SXXNufzrppI/AAAAAAAAAI4/ztUzM3_xi-w/s1600-h/Picture+1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 271px;" src="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SXXNufzrppI/AAAAAAAAAI4/ztUzM3_xi-w/s320/Picture+1.png" alt="" id="BLOGGER_PHOTO_ID_5293363135739831954" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Now right-click again on your project name in the &lt;span style="font-style: italic;"&gt;Project Explorer&lt;/span&gt; and select &lt;span style="font-style: italic;"&gt;Properties&lt;/span&gt;.&lt;br /&gt;Move to &lt;span style="font-style: italic;"&gt;C/C++ General -&gt; Paths and Symbols&lt;/span&gt; and press the &lt;span style="font-style: italic;"&gt;Add&lt;/span&gt; button.&lt;br /&gt;Select &lt;span style="font-style: italic;"&gt;Frameworks/Ogre.framework/Header&lt;/span&gt; directory in you workspace and check &lt;span style="font-style: italic;"&gt;Add to all configurations, Add to all languages &lt;/span&gt;and &lt;span style="font-style: italic;"&gt;Is a workspace path&lt;/span&gt;.&lt;br /&gt;Do the same for &lt;span style="font-style: italic;"&gt;Frameworks/Cg.framework/Header &lt;/span&gt;&lt;span&gt;and &lt;/span&gt;&lt;span style="font-style: italic;"&gt;Frameworks/include&lt;/span&gt;&lt;span&gt; directories.&lt;/span&gt;&lt;br /&gt;Press &lt;span class="Apple-style-span" style="font-style: italic;"&gt;Add&lt;/span&gt; again, select &lt;span style="font-style: italic;"&gt;/Developer/Headers/FlatCarbon&lt;/span&gt; folder and check only &lt;span style="font-style: italic;"&gt;Add to all configurations, Add to all languages&lt;/span&gt;&lt;span&gt; this time.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SXXgfalrpeI/AAAAAAAAAJo/cNfMOI8vUrI/s1600-h/Picture+6.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 267px;" src="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SXXgfalrpeI/AAAAAAAAAJo/cNfMOI8vUrI/s320/Picture+6.png" alt="" id="BLOGGER_PHOTO_ID_5293383767361824226" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SXXQVV7AWrI/AAAAAAAAAJA/oZi6QEFpVQs/s1600-h/Picture+2.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Move to &lt;span style="font-style: italic;"&gt;Library Paths&lt;/span&gt; tab and press &lt;span class="Apple-style-span" style="font-style: italic;"&gt;Add;&lt;/span&gt; again check &lt;span style="font-style: italic;"&gt;Add to all configurations, Add to all languages &lt;/span&gt;and &lt;span style="font-style: italic;"&gt;Is a workspace &lt;/span&gt;&lt;span style="font-style: italic;"&gt;path&lt;/span&gt;&lt;span&gt; and add &lt;span style="font-style: italic;"&gt;Framworks/lib/Release directory.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1NfXJ8vxGrs/SXXgy8Hze4I/AAAAAAAAAJw/CyHGqYBFbWE/s1600-h/Picture+8.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 258px;" src="http://2.bp.blogspot.com/_1NfXJ8vxGrs/SXXgy8Hze4I/AAAAAAAAAJw/CyHGqYBFbWE/s320/Picture+8.png" alt="" id="BLOGGER_PHOTO_ID_5293384102780828546" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1NfXJ8vxGrs/SXXSt4qc52I/AAAAAAAAAJQ/UEDRYCpFqkA/s1600-h/Picture+3.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Now select &lt;span style="font-style: italic;"&gt;C/C++ Build -&gt;Settings&lt;/span&gt; from the tree menu on the left and set the configuration selector to &lt;span style="font-style: italic;"&gt;[ All configurations ]&lt;/span&gt;.&lt;br /&gt;Click on &lt;span style="font-style: italic;"&gt;C++ Linker -&gt; Libraries&lt;/span&gt; and add &lt;span style="font-style: italic;"&gt;ois&lt;/span&gt; to &lt;span style="font-style: italic;"&gt;Libraries&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SXXhRre2C1I/AAAAAAAAAJ4/9lGXCDZfGW8/s1600-h/Picture+7.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 259px;" src="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SXXhRre2C1I/AAAAAAAAAJ4/9lGXCDZfGW8/s320/Picture+7.png" alt="" id="BLOGGER_PHOTO_ID_5293384630890007378" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1NfXJ8vxGrs/SXXUbPuCVtI/AAAAAAAAAJY/Wl66zdv49kc/s1600-h/Picture+4.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Finally click on &lt;span style="font-style: italic;"&gt;C++ Linker -&gt; Miscellaneous&lt;/span&gt; and write &lt;span style="font-style: italic;"&gt;-F${CWD}/../Frameworks -framework Ogre -framework Carbon -framework IOKit -framework Cg&lt;/span&gt; in the &lt;span style="font-style: italic;"&gt;Linker flags&lt;/span&gt; text box.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SXXVyX2b8bI/AAAAAAAAAJg/Pyf-EXX0yKU/s1600-h/Picture+5.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 237px;" src="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SXXVyX2b8bI/AAAAAAAAAJg/Pyf-EXX0yKU/s320/Picture+5.png" alt="" id="BLOGGER_PHOTO_ID_5293371998416400818" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-size:180%;"&gt;Last bug-fix&lt;/span&gt;&lt;br /&gt;Now your IDE is correctly configured but your application will not compile due to an error within the &lt;span style="font-style: italic;"&gt;Frameworks/Ogre.framework/Headers/OSX/OgreTimerImp.h&lt;/span&gt; file. Edit this file and change the line &lt;span style="font-style: italic;"&gt;#include &amp;lt;ogre/OgrePrerequisites.h&amp;gt;&lt;/span&gt; to &lt;span style="font-style: italic;"&gt;#include &amp;lt;OgrePrerequisites.h&amp;gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Conclusion and last hints&lt;/span&gt;&lt;br /&gt;Now this setup will allow you to compile any Ogre based application, however, if you want to work with Ogre official tutorials, you have to go through some further steps:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Import in you application the headers required by the tutorial you are working on (most of the times ExampleApplication.h and ExampleFrameListener.h are required).&lt;br /&gt;You can find them in the &lt;span style="font-style: italic;"&gt;Samples &lt;/span&gt;directory of your OgreSDK.&lt;/li&gt;&lt;li&gt;Import the &lt;span style="font-style: italic;"&gt;Media &lt;/span&gt;directory of your OgreSDK into your project's root (this directory contains all the tutorials required textures, models, etc... )&lt;/li&gt;&lt;li&gt;Import the &lt;span style="font-style: italic;"&gt;.cfg &lt;/span&gt;files from you OgreSDK and modify them to match the path of your &lt;span style="font-style: italic;"&gt;Media &lt;/span&gt;directory (typically ../Media is good).&lt;/li&gt;&lt;li&gt;Add this command: &lt;span style="font-style: italic;"&gt;install -d ${CWD}/Contents/Resources &amp;amp;&amp;amp; cp -f ${CWD}/../*.cfg ${CWD}/Contents/Resources&lt;/span&gt; to your project's Post-build step (set it in the &lt;span style="font-style: italic;"&gt;Build steps&lt;/span&gt; tab of the &lt;span style="font-style: italic;"&gt;C/C++ Build -&gt; Settings &lt;/span&gt;configuration form and remember to do it for all configurations)&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/801021240915912006-5526161166059970581?l=digitalapes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://digitalapes.blogspot.com/feeds/5526161166059970581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=801021240915912006&amp;postID=5526161166059970581' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/5526161166059970581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/5526161166059970581'/><link rel='alternate' type='text/html' href='http://digitalapes.blogspot.com/2009/01/develop-ogre3d-applications-using.html' title='Develop Ogre3D applications using Eclipse on Mac OS X'/><author><name>Paolo</name><uri>http://www.blogger.com/profile/16172678310067045282</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1NfXJ8vxGrs/R4AzHLSp1yI/AAAAAAAAABI/QMrDFb_9KBw/S220/rastapal.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1NfXJ8vxGrs/SXXNufzrppI/AAAAAAAAAI4/ztUzM3_xi-w/s72-c/Picture+1.png' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-801021240915912006.post-351866769761784825</id><published>2009-01-19T17:10:00.012+01:00</published><updated>2009-01-21T10:17:15.520+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ZappOne.tv Tutorial FAQ'/><title type='text'>ZappOne.tv FAQ</title><content type='html'>In this little FAQ I will address some common questions about ZappOne.tv&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;First things first, what's this thing all about ?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;ZappOne.tv is a Rich Web 2.0 Interactive Ajax Enabled Multimedia Videoclip Streaming Internet Application (oh yes and also iSomething).&lt;/div&gt;&lt;div&gt;Said with poorer words, it's a Web application based on a very simple concept: create an enhanced experience with YouTube.&lt;/div&gt;&lt;div&gt;In straight words, a continuous stream of YouTube videoclips without the hassle of clicking on next video's link.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;How to reach this paradise ?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Simply go to &lt;a href="http://www.zappone.tv/"&gt;ZappOne.tv&lt;/a&gt; website and start using it&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;What can i do with it?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Well, you can search YouTube media library for your favourite videoclips and watch them one after another.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Ok, but how ?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The easiest way is to put in some keywords into the tex box on the homepage, then you can press on the GO! button and enjoy your videclips.&lt;/div&gt;&lt;div&gt;Following you can find two screenshots along with some explaination about other functions.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;This is the main search page for ZappOne.tv&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_95zInHFbLAg/SXYASuIGEvI/AAAAAAAAABw/m4Uhdga-J70/s1600-h/Search.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 258px;" src="http://1.bp.blogspot.com/_95zInHFbLAg/SXYASuIGEvI/AAAAAAAAABw/m4Uhdga-J70/s400/Search.PNG" alt="" id="BLOGGER_PHOTO_ID_5293418733640225522" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Keyword to search for: here you can insert your keywords separated by a space&lt;/li&gt;&lt;li&gt;Ordering: this selection determines which order your results will be displayed (default is by most relevant to lesser)&lt;/li&gt;&lt;li&gt;Filter criteria: these options let you filter and further optimize your search results by selecting only ones that match checked categories (this is very usefull for music :P )&lt;/li&gt;&lt;li&gt;Recent tags: just to remember what you have searched so far&lt;/li&gt;&lt;li&gt;Popular tags: the classic Web 2.0 tag cloud containing most used keywords by every user browsing through ZappOne.tv (you can click them to add to your search)&lt;/li&gt;&lt;li&gt;Submit Button: the button with a "Go!" label. As it's name suggests, it starts your experience. Plain and simple.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;This is an example of a result page&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_95zInHFbLAg/SXYCge3WhZI/AAAAAAAAAB4/J19NwOOox64/s1600-h/clip2.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 257px;" src="http://4.bp.blogspot.com/_95zInHFbLAg/SXYCge3WhZI/AAAAAAAAAB4/J19NwOOox64/s400/clip2.PNG" alt="" id="BLOGGER_PHOTO_ID_5293421169084892562" border="0" /&gt;&lt;/a&gt;&lt;ul&gt;&lt;li&gt;Current video: Just to remember you what are you looking at. Also contains a link to the original media on YouTube&lt;/li&gt;&lt;li&gt;Playlist: a strip with the thumbnails of your search results. You can scroll it and peek what will be the next videoclip to be shown.&lt;/li&gt;&lt;li&gt;Remove button: by hovering over a thumbnail you will be able to exclude it from the playlist by simply clicking on this red button (you can then restore it by pressing it again)&lt;/li&gt;&lt;li&gt;Link button: have you found a particular playlist you want to share with your best friends ? Here's a link to show them from this point on.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Who developed this marvel ?&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.digitalapes.net/"&gt;digitalapes&lt;/a&gt;, of course ;)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Now tell me the real thing: how much does it cost ?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Nothing. ZappOne.tv is absolutly costless and ad-free. The only thing we ask you is to give us a little of feedback on your experience. That's it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;What am I waiting for ?&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Don't know ... go visit &lt;a href="http://www.zappone.xn--tv-pka/"&gt;ZappOne.tv&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/801021240915912006-351866769761784825?l=digitalapes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.zapponetv.tk' title='ZappOne.tv FAQ'/><link rel='replies' type='application/atom+xml' href='http://digitalapes.blogspot.com/feeds/351866769761784825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=801021240915912006&amp;postID=351866769761784825' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/351866769761784825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/351866769761784825'/><link rel='alternate' type='text/html' href='http://digitalapes.blogspot.com/2009/01/zapponetv-faq.html' title='ZappOne.tv FAQ'/><author><name>Ste</name><uri>http://www.blogger.com/profile/06788236330368835587</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_95zInHFbLAg/SXYASuIGEvI/AAAAAAAAABw/m4Uhdga-J70/s72-c/Search.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-801021240915912006.post-3034873497733699765</id><published>2008-11-13T10:58:00.016+01:00</published><updated>2008-11-17T11:17:33.210+01:00</updated><title type='text'>Developing mobile applications using Gear episode 3: Managing user inputs</title><content type='html'>&lt;p&gt;This tutorial will discuss how to handle user inputs in gear based applications and will guide you through the development of a simple picture viewing application.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;User input is generally handled by classes inheriting from GWCanvas (thus also GWForm, GWList, GWGrid, etc…). In J2ME applications there are 3 types of inputs available: commands (triggered by soft keys), keypad and touch screen.&lt;br /&gt;In Gear based applications touch screen events can be handled in two different ways: as pointer events and as gesture based events.&lt;/p&gt;&lt;p&gt;Command and gesture triggered events don't need to be handled necessarily in the widgets classes since they use a listener based paradigm, but it is common practice to do so.&lt;/p&gt;&lt;p&gt;To start developing the picture viewer demo we'll have first to create a Gear based J2ME application as explained in the first tutorial "&lt;a href="http://digitalapes.blogspot.com/2008/07/developing-mobile-applications-using.html"&gt;Developing mobile applications using Gear episode 1: Create the first empty application&lt;/a&gt;".&lt;/p&gt;&lt;p&gt;The picture viewer demo will permit the user to browse through a set of images included as resources in the JAR archive and to see them in full-screen mode.&lt;/p&gt;&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SRwEackxKBI/AAAAAAAAAH4/Dy8sc8NbThY/s1600-h/GearTouchDemo.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 209px;" src="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SRwEackxKBI/AAAAAAAAAH4/Dy8sc8NbThY/s320/GearTouchDemo.jpg" alt="" id="BLOGGER_PHOTO_ID_5268090516510156818" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Note that the content of this tutorial applies to version &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=234344&amp;amp;package_id=284481"&gt;1.1.1 of Gear framework&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;Step 1: Creating the photo browser widget&lt;/span&gt;&lt;/p&gt;&lt;p&gt;First let's create the PhotoBrowser class, make it inherit from GWScrollableList and set it's title and its title icon.&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;public class PhotoBrowser extends GWScrollableList {&lt;br /&gt;public PhotoBrowser() {&lt;br /&gt; setTitle("Photo browser");&lt;br /&gt; setTitleIcon("/Digitalapes.png");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Then let's add two commands to the interface (View and Exit).&lt;br /&gt;To do so we have to make PhotoBrowser implement GWCommandListener interface, we have to register it self as a command listener and finally add two commands.&lt;/p&gt;&lt;pre&gt;public class PhotoBrowser extends GWScrollableList&lt;br /&gt;implements GWCommandListener {&lt;br /&gt; &lt;br /&gt;Command viewCommand = new Command("View",Command.ITEM,0);&lt;br /&gt; &lt;br /&gt;public PhotoBrowser() {&lt;br /&gt;setTitle("Photo browser");&lt;br /&gt;setTitleIcon("/Digitalapes.png");&lt;br /&gt;setCommandListener(this);&lt;br /&gt;addCommand(viewCommand);&lt;br /&gt;addCommand(CommonCommands.EXIT);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void commandAction(Command command, GWCanvas sender) {&lt;br /&gt;}&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;Now we need to make the photo browser show the images thumbnail.&lt;br /&gt;This step requires to load the pictures in the photo browser constructor, note that we'll suppose to have a list of the available pictures contained in the PhotoList class (the class code, along with the pictures is included in the demo source code).&lt;/p&gt;&lt;pre&gt;public PhotoBrowser() {&lt;br /&gt;setTitle("Photo browser");&lt;br /&gt;setTitleIcon("/Digitalapes.png");&lt;br /&gt;setCommandListener(this);&lt;br /&gt;setStretchIcons(true);&lt;br /&gt;for (int i=0;i &amp;lt; PhotoList.list.length;i++){&lt;br /&gt; ListItem tmp =&lt;br /&gt;    new ListItem(PhotoList.list[i],"/"+PhotoList.list[i]);&lt;br /&gt; tmp.setMinVisibleLines(3);&lt;br /&gt; addItem(tmp);&lt;br /&gt;}&lt;br /&gt;addCommand(viewCommand);&lt;br /&gt;addCommand(CommonCommands.EXIT);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Now photo browser displays all the thumbnails but no actions are associated to the user inputs.&lt;br /&gt;Let's associate a quit action to the Exit command pressure and a let's make the PhotoView class (that we are going to implement in the next step) displayed when the View command or the fire button are pressed.&lt;br /&gt;At the end your class should look like this one:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;public class PhotoBrowser extends GWScrollableList implements&lt;br /&gt;GWCommandListener {&lt;br /&gt; &lt;br /&gt;Command viewCommand = new Command("View",Command.ITEM,0);&lt;br /&gt; &lt;br /&gt;public PhotoBrowser() {&lt;br /&gt;setTitle("Photo browser");&lt;br /&gt;setTitleIcon("/Digitalapes.png");&lt;br /&gt;setCommandListener(this);&lt;br /&gt;setStretchIcons(true);&lt;br /&gt;for (int i=0;i &amp;lt; PhotoList.list.length;i++){&lt;br /&gt; ListItem tmp =&lt;br /&gt;   new ListItem(PhotoList.list[i],"/"+PhotoList.list[i]);&lt;br /&gt;&lt;br /&gt; tmp.setMinVisibleLines(3);&lt;br /&gt; addItem(tmp);&lt;br /&gt;}&lt;br /&gt;addCommand(viewCommand);&lt;br /&gt;addCommand(CommonCommands.EXIT);&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;public void itemClicked(ImageItem clickedItem) {&lt;br /&gt;commandAction(viewCommand, this);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void itemSelected(ImageItem selectedItem) {&lt;br /&gt;super.itemSelected(selectedItem);&lt;br /&gt;PhotoList.setCurrentPhoto(getSelectedIndex());&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void commandAction(Command command, GWCanvas sender) {&lt;br /&gt;if (command == viewCommand)&lt;br /&gt; EventManager.getInstance().enqueueEvent(&lt;br /&gt;     new DisplayWidget(this,SlideShow.class));&lt;br /&gt;else if (command == CommonCommands.EXIT)&lt;br /&gt; EventManager.getInstance().enqueueEvent(new QuitEvent(this));&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;protected boolean showCheck(Display display, EventArg eventArgs) {&lt;br /&gt;setSelectedIndex(PhotoList.getCurrentPhotoIndex());&lt;br /&gt;return true;&lt;br /&gt;} &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;Step 2: Creating the photo viewer widget&lt;/span&gt;&lt;/p&gt;&lt;p&gt;As before the first step is creating the class (this time inheriting from GWCanvas), setting title and icon, and managing commands&lt;/p&gt;&lt;pre&gt;public class SlideShow extends GWCanvas implements GWCommandListener{&lt;br /&gt;&lt;br /&gt;Command browseCommand = new Command("Browse",Command.OK,0);&lt;br /&gt; &lt;br /&gt;public SlideShow() {&lt;br /&gt;setTitle("Photo viewer");&lt;br /&gt;setTitleIcon("/Digitalapes.png");&lt;br /&gt;setCommandListener(this);&lt;br /&gt;addCommand(browseCommand);&lt;br /&gt;addCommand(CommonCommands.EXIT);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void contentPaint(Graphics g, int x, int y, int w, int h) {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void commandAction(Command command, GWCanvas sender) {&lt;br /&gt;if (command == browseCommand)&lt;br /&gt; EventManager.getInstance().enqueueEvent(new&lt;br /&gt;       DisplayWidget(this,PhotoBrowser.class));&lt;br /&gt;else if (command == CommonCommands.EXIT)&lt;br /&gt; EventManager.getInstance().enqueueEvent(new QuitEvent(this));&lt;br /&gt;}&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;Now let's handle the current picture paintig: to paint something in the GWCanvasthe paint operations should be performed in the contentPaint() method, using the parameter as paintable area bounds.&lt;br /&gt;In order to make this widget display the picture requested by the PhotoBrowser, we should also put the proper loading code in the showCheck() method.&lt;/p&gt;&lt;pre&gt;String currentImage=null;&lt;br /&gt;&lt;br /&gt;protected void contentPaint(Graphics g, int x, int y, int w, int h) {&lt;br /&gt;g.drawImage(ImageResourcesBuffer.getImageResource(&lt;br /&gt;   currentImage, w-this.formPadding*2, h-this.formPadding*2),&lt;br /&gt;    x+w/2, y+h/2, Graphics.VCENTER|Graphics.HCENTER);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected boolean showCheck(Display display, EventArg eventArgs) {&lt;br /&gt;String photoName = PhotoList.getCurrentPhoto();&lt;br /&gt;currentImage = "/"+photoName;&lt;br /&gt;setTitle("Photo view - "+photoName.substring(0, photoName.length()-4));&lt;br /&gt;return true;&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;Now let's associate to the left and right key pressed events a slide action, making the visualize respectively the next and the previous picture&lt;/p&gt;&lt;pre&gt;protected void rightArrowPressed() {&lt;br /&gt;PhotoList.getNextPhoto();&lt;br /&gt;EventManager.getInstance().enqueueEvent(new&lt;br /&gt;   DisplayWidget(this,SlideShow.class,SlideRight.class));&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;protected void leftArrowPressed() {&lt;br /&gt;PhotoList.getPrevPhoto();&lt;br /&gt;EventManager.getInstance().enqueueEvent(new&lt;br /&gt;   DisplayWidget(this,SlideShow.class,SlideLeft.class));&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;The last step for this widget is the handling of touch screen gestures. To handle touch screen gestures we have to make our class implement the GWGestureListener interface, register it as a gesture listener and then implement the required callbacks.&lt;br /&gt;Finally your class should look like this one:&lt;/p&gt;&lt;pre&gt;public class SlideShow extends GWCanvas&lt;br /&gt;   implements GWCommandListener, GWGestureListener{&lt;br /&gt;Command browseCommand = new Command("Browse",Command.OK,0);&lt;br /&gt;String currentImage=null;&lt;br /&gt;&lt;br /&gt;public SlideShow() {&lt;br /&gt;setTitle("Photo viewer");&lt;br /&gt;setTitleIcon("/Digitalapes.png");&lt;br /&gt;setCommandListener(this);&lt;br /&gt;setGestureListener(this);&lt;br /&gt;addCommand(browseCommand);&lt;br /&gt;addCommand(CommonCommands.EXIT);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void contentPaint(Graphics g, int x, int y, int w, int h) {&lt;br /&gt;g.drawImage(ImageResourcesBuffer.getImageResource(&lt;br /&gt;           currentImage, w-this.formPadding*2, h-this.formPadding*2),&lt;br /&gt;           x+w/2, y+h/2, Graphics.VCENTER|Graphics.HCENTER);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void reset() {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void commandAction(Command command, GWCanvas sender) {&lt;br /&gt;if (command == browseCommand)&lt;br /&gt;   EventManager.getInstance().enqueueEvent(&lt;br /&gt;           new DisplayWidget(this,PhotoBrowser.class));&lt;br /&gt;else if (command == CommonCommands.EXIT)&lt;br /&gt;   EventManager.getInstance().enqueueEvent(new QuitEvent(this));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void downToUpScrollGesture() { &lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;public void upToDownScrollGesture() {&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;public void rightToLeftScrollGesture() {&lt;br /&gt;PhotoList.getNextPhoto();&lt;br /&gt;EventManager.getInstance().enqueueEvent(&lt;br /&gt;    new DisplayWidget(this,SlideShow.class,SlideRight.class));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void leftToRightScrollGesture() {&lt;br /&gt;PhotoList.getPrevPhoto();&lt;br /&gt;EventManager.getInstance().enqueueEvent(&lt;br /&gt;    new DisplayWidget(this,SlideShow.class,SlideLeft.class));&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;protected void rightArrowPressed() {&lt;br /&gt;PhotoList.getNextPhoto();&lt;br /&gt;EventManager.getInstance().enqueueEvent(new&lt;br /&gt;     DisplayWidget(this,SlideShow.class,SlideRight.class));&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;protected void leftArrowPressed() {&lt;br /&gt;PhotoList.getPrevPhoto();&lt;br /&gt;EventManager.getInstance().enqueueEvent(new&lt;br /&gt;   DisplayWidget(this,SlideShow.class,SlideLeft.class));&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;protected boolean showCheck(Display display, EventArg eventArgs) {&lt;br /&gt;String photoName = PhotoList.getCurrentPhoto();&lt;br /&gt;currentImage = "/"+photoName;&lt;br /&gt;setTitle("Photo view - "+photoName.substring(0, photoName.length()-4));&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;Step 3: Adding the glue&lt;/span&gt;&lt;/p&gt;&lt;p&gt;First we need to implement the class containing the pictures index:&lt;/p&gt;&lt;pre&gt;public class PhotoList {&lt;br /&gt;&lt;br /&gt;private static int selectedPhotoIndex=0;&lt;br /&gt;private PhotoList() {&lt;br /&gt;}&lt;br /&gt;public static final String[] list = {&lt;br /&gt;  "Church.jpg",&lt;br /&gt;  "Dema.jpg",&lt;br /&gt;  "Marco.jpg",&lt;br /&gt;  "Paolo.jpg",&lt;br /&gt;  "PizBoe.jpg",&lt;br /&gt;  "SellaRonda.jpg",&lt;br /&gt;  "Track22.jpg",&lt;br /&gt;  "Zoncolan.jpg"&lt;br /&gt;};&lt;br /&gt;public static String getNextPhoto(){&lt;br /&gt;  selectedPhotoIndex++;&lt;br /&gt;  if (selectedPhotoIndex&amp;gt;=list.length)&lt;br /&gt;    selectedPhotoIndex=0;&lt;br /&gt;  return getCurrentPhoto();&lt;br /&gt;} &lt;br /&gt;public static String getPrevPhoto(){&lt;br /&gt;  selectedPhotoIndex--;&lt;br /&gt;  if (selectedPhotoIndex&amp;lt;0)&lt;br /&gt;    selectedPhotoIndex=list.length-1;&lt;br /&gt;  return getCurrentPhoto();  &lt;br /&gt;}&lt;br /&gt;public static void setCurrentPhoto(int i){&lt;br /&gt;  if (i&amp;gt;=0 &amp;amp;&amp;amp; i&amp;lt;list.length)&lt;br /&gt;    selectedPhotoIndex = i;&lt;br /&gt;} &lt;br /&gt;public static String getCurrentPhoto(){&lt;br /&gt;  return list[selectedPhotoIndex];   &lt;br /&gt;} &lt;br /&gt;public static int getCurrentPhotoIndex(){&lt;br /&gt;  return selectedPhotoIndex;   &lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;And finally we have to enable graphic effects in the Gear midlet (to see the transitions) and display the PhotoBrowser at midlet initialization.&lt;/p&gt;&lt;pre&gt;setGraphicEffectsEnabled(true);&lt;br /&gt;EventManager.getInstance().enqueueEvent(new DisplayWidget(this,PhotoBrowser.class));&lt;/pre&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;Conclusions&lt;/span&gt;&lt;/p&gt;&lt;p&gt;The application we have just created shows how to handle different types of user inputs and gives some basic knowledge about creation of custom graphic widgets and about usage of advanced graphic effects.&lt;br /&gt;It is possible to download the source code and the binary package of this application from &lt;a href="https://sourceforge.net/project/showfiles.php?group_id=234344&amp;amp;package_id=284913"&gt;Gear's download page&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/801021240915912006-3034873497733699765?l=digitalapes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://digitalapes.blogspot.com/feeds/3034873497733699765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=801021240915912006&amp;postID=3034873497733699765' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/3034873497733699765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/3034873497733699765'/><link rel='alternate' type='text/html' href='http://digitalapes.blogspot.com/2008/11/developing-mobile-applications-using.html' title='Developing mobile applications using Gear episode 3: Managing user inputs'/><author><name>Paolo</name><uri>http://www.blogger.com/profile/16172678310067045282</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1NfXJ8vxGrs/R4AzHLSp1yI/AAAAAAAAABI/QMrDFb_9KBw/S220/rastapal.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_1NfXJ8vxGrs/SRwEackxKBI/AAAAAAAAAH4/Dy8sc8NbThY/s72-c/GearTouchDemo.jpg' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-801021240915912006.post-3328120886345584663</id><published>2008-09-05T10:57:00.046+02:00</published><updated>2008-09-06T15:15:06.261+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WTK'/><category scheme='http://www.blogger.com/atom/ns#' term='J2Me'/><category scheme='http://www.blogger.com/atom/ns#' term='Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='Form'/><category scheme='http://www.blogger.com/atom/ns#' term='Gear'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='Widgets'/><title type='text'>Developing mobile applications using Gear episode 2: Start using gear widgets and events</title><content type='html'>The previous episode of this tutorial covered all the necessary steps to setup a development environment for J2ME applications using Eclipse, EclipseME end Gear.&lt;br /&gt;The previous instructions (&lt;a href="http://digitalapes.blogspot.com/2008/07/developing-mobile-applications-using.html"&gt;available here&lt;/a&gt;) are still valid except for the Gear framework version since a new release is now available for download (&lt;a href="https://sourceforge.net/project/showfiles.php?group_id=234344"&gt;Gear 1.0.0&lt;/a&gt;) .&lt;br /&gt;This tutorial will cover the basic steps required to develop a simple application displaying two forms using Gear widgets system end its event based paradigm.&lt;br /&gt;At the end of this tutorial you will have produced an application like the one you can see in the following screen shots:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SMFAowmS_VI/AAAAAAAAAGg/lwRbqA63icU/s1600-h/screenshots.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SMFAowmS_VI/AAAAAAAAAGg/lwRbqA63icU/s320/screenshots.gif" alt="" id="BLOGGER_PHOTO_ID_5242542510220442962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Step 1: Create the first GearMidlet&lt;/span&gt;&lt;br /&gt;In the step 3 of the previous tutorial we have created an empty J2ME application (midlet suite) and we have added Gear to it.&lt;br /&gt;The midlet suite itselft is not a real application, it's a container for one or more midlet and each midlet is potentially a completely independent application, however most of the midlet suites available contain just one midlet thus a midlet suite is commonly considered equivalent to a mobile application.&lt;br /&gt;Anyay, to start developing our application, we need to create a midlet that will be considered the execution entry point of our midlet suite.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Enter the "New-&gt;Other" menu and select "J2ME Midlet"&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SMFEqjYbk9I/AAAAAAAAAGo/Mr4NWOLvy08/s1600-h/screenshot3.png"&gt;&lt;img style="cursor: pointer;" src="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SMFEqjYbk9I/AAAAAAAAAGo/Mr4NWOLvy08/s320/screenshot3.png" alt="" id="BLOGGER_PHOTO_ID_5242546939078874066" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Enter the midlet name, the package and change the superclass to "gear.application.GearMidlet"&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SMFFWFx8M4I/AAAAAAAAAGw/wdSdEijgtgA/s1600-h/screenshot4.png"&gt;&lt;img style="cursor: pointer;" src="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SMFFWFx8M4I/AAAAAAAAAGw/wdSdEijgtgA/s320/screenshot4.png" alt="" id="BLOGGER_PHOTO_ID_5242547687047050114" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Now you have the midlet created it still does nothing but you can try executing it by right clicking on it and selecting "Run As-&gt;Emulated J2ME Midlet" as shown in the following screen shot.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SMFOXtQubxI/AAAAAAAAAHY/24BozcnaYAA/s1600-h/Screenshot.png"&gt;&lt;img style="cursor: pointer;" src="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SMFOXtQubxI/AAAAAAAAAHY/24BozcnaYAA/s320/Screenshot.png" alt="" id="BLOGGER_PHOTO_ID_5242557610429673234" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;NOTE:&lt;/span&gt; In order to continue developing the application of this tutorial it is necessary to add this icon &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SMFMCoFKNsI/AAAAAAAAAHQ/nkVeM-SnVMM/s1600-h/digitalapes.png"&gt;&lt;img style="cursor: pointer; width: 16px; height: 16px;" src="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SMFMCoFKNsI/AAAAAAAAAHQ/nkVeM-SnVMM/s320/digitalapes.png" alt="" id="BLOGGER_PHOTO_ID_5242555049238476482" border="0" /&gt;&lt;/a&gt; to the "res" folder of your project.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Step 2: Create two forms using GWGrid and GWList&lt;/span&gt;&lt;br /&gt;To crate a form using Gear Widgets system simply create a class and inherit one of the available form types.&lt;br /&gt;In Gear version 1.0.0 there are four forms already implemented (GWText, GWGrid, GWList and GWScrollableList) each of these forms can be extended to add any functionality and new forms can be created by extending GWCanvas and GWForm classes.&lt;br /&gt;In this article we'll learn how to display two forms containing 4 items using GWGrid and GWList classes.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;First we have to create two classes and make one inherit from GWGrid and the other one from GWList, the two classes should look similar to these two:&lt;br /&gt;&lt;pre&gt;public class TestGWGrid extends GWGrid{&lt;br /&gt;public TestGWGrid() {&lt;br /&gt;super();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre&gt;public class TestGWList extends GWList{&lt;br /&gt;public TestGWList() {&lt;br /&gt;super();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Now we have to fill both classes with the items to be displayed and we have to set the title and the title icon, to do so we have to put the following code in the TestGWGrid constructor:&lt;br /&gt;&lt;pre&gt;// Constructs the grid with 2 rows and 2 columns&lt;br /&gt;super(2,2);&lt;br /&gt;&lt;br /&gt;// Set the Grid to stretch properly the icons&lt;br /&gt;setStretchIcons(true);&lt;br /&gt;&lt;br /&gt;// Add four items to the Grid&lt;br /&gt;addItem("Item 0", "/digitalapes.png");&lt;br /&gt;addItem("Item 1", "/digitalapes.png");&lt;br /&gt;addItem("Item 2", "/digitalapes.png");&lt;br /&gt;addItem("Item 3", "/digitalapes.png");&lt;br /&gt;&lt;br /&gt;// Set the grid title&lt;br /&gt;setTitle("TestGWGrid");&lt;br /&gt;&lt;br /&gt;// Set the grid title icon&lt;br /&gt;setTitleIcon("/digitalapes.png");&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;and the following code in TestGWList constructor:&lt;pre&gt;&lt;br /&gt;super();&lt;br /&gt;&lt;br /&gt;// Set the List to stretch properly the icons&lt;br /&gt;setStretchIcons(true);&lt;br /&gt;&lt;br /&gt;// Add four items to the list&lt;br /&gt;addItem("Item 0", "/digitalapes.png");&lt;br /&gt;addItem("Item 1", "/digitalapes.png");&lt;br /&gt;addItem("Item 2", "/digitalapes.png");&lt;br /&gt;addItem("Item 3", "/digitalapes.png");&lt;br /&gt;&lt;br /&gt;// Set the list title&lt;br /&gt;setTitle("TestGWGrid");&lt;br /&gt;&lt;br /&gt;// Set the list title icon&lt;br /&gt;setTitleIcon("/digitalapes.png");&lt;br /&gt;&lt;/pre&gt;Setting title and title icon is not compulsory, if none is set the top bar is not displayed&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Finally to interact with the user we'll add two commands to the forms and we'll intercept these commands.&lt;br /&gt;To do this we have to add the following code at the end of both constructors:&lt;br /&gt;&lt;pre&gt;// Add two commands&lt;br /&gt;addCommand(CommonCommands.NEXT);&lt;br /&gt;addCommand(CommonCommands.EXIT);&lt;br /&gt;&lt;br /&gt;// Add this class as a command listener&lt;br /&gt;addCommandListener(this);&lt;br /&gt;&lt;/pre&gt;And both classes have to implement the "GWCommandListener" interface this way:&lt;br /&gt;&lt;pre&gt;public void commandAction(Command command, GWCanvas sender) {&lt;br /&gt;if (command == CommonCommands.NEXT){&lt;br /&gt;// Do something&lt;br /&gt;} else if (command == CommonCommands.EXIT){&lt;br /&gt;// Do something else&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:130%;"&gt;Step 3: Connecting everything using events&lt;br /&gt;&lt;/span&gt;The Gear architecture is based on a multi threading paradigm, so, to permit easy thread to thread communication, Gear provides an event based communication system.&lt;br /&gt;Each event is an object of a class inheriting from the "Event" class, an event may be dispatched by any object and caught by any other.&lt;br /&gt;Dispatching an event requires simply to call the method "enqueueEvent" of the "EventManager" singleton.&lt;br /&gt;Catching an event is a bit more complicated: the class which wants to catch the event should implement the "EventHost" interface and should register to the "EventManager" using the "registerHost" method.&lt;br /&gt;By default the GearMidlet catches the "Quit" and the "DisplayWidget" events. When receiving the first one the midlet will call the "onDestroy" callback and will quit the application if the return value is true.  When receiving the "DisplayWidget" event the midlet will handle the eventual widget instantiation and will make the widget visible on screen and active.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;To start a widget on midlet start we'll have to dispatch a "DisplayWidget" event in the midlet constructor.&lt;br /&gt;&lt;pre&gt;public TestGearMidlet() {&lt;br /&gt;// This event requires the midlet to handle&lt;br /&gt;// instantiation of a TestGWGrid and display it&lt;br /&gt;EventManager.GetInstance().enqueueEvent(&lt;br /&gt;                 new DisplayWidget(this,TestGWGrid.class));&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Georgia,serif;"&gt;To permit the user to exit and switch between the two forms we'll have to add the proper event dispatching functions in the command handling callbacks.&lt;br /&gt;In TestGWList command callback we'll have to put the following code:&lt;br /&gt;&lt;pre&gt;public void commandAction(Command command, GWCanvas sender) {&lt;br /&gt;if (command == CommonCommands.NEXT){&lt;br /&gt;EventManager.GetInstance().enqueueEvent(&lt;br /&gt;                  new DisplayWidget(this,TestGWList.class));&lt;br /&gt;} else if (command == CommonCommands.EXIT){&lt;br /&gt;EventManager.GetInstance().enqueueEvent(&lt;br /&gt;                  new Quit(this));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;And in TestGWGrid command callback we'll have to put this code:&lt;br /&gt;&lt;pre&gt;public void commandAction(Command command, GWCanvas sender) {&lt;br /&gt;if (command == CommonCommands.NEXT){&lt;br /&gt;EventManager.GetInstance().enqueueEvent(&lt;br /&gt;                 new DisplayWidget(this,TestGWList.class));&lt;br /&gt;} else if (command == CommonCommands.EXIT){&lt;br /&gt;EventManager.GetInstance().enqueueEvent(&lt;br /&gt;                  new Quit(this));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;This way, when the user will press the "Exit" command a "Quit" event will be dispatched and midlet will close.&lt;br /&gt;And, when the user will press the "Next" command a "DisplayWidget" event will be dispatched and the midlet will change the currently displayed forom.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:130%;"&gt;Conclusions&lt;br /&gt;&lt;/span&gt;The application we have just created shows the structure of a typical Gear based application and gives some examples of basic widgets handling.&lt;br /&gt;It is possible to download the source code and the binary package of this application from &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=234344&amp;amp;package_id=284913"&gt;this page&lt;/a&gt;.&lt;br /&gt;In the next tutorial more advanced features of the Gear widgets system will be explained (like transitions, list and grid items customization, arrows and fire keys handling, themes, etc...), then the tutorials will focus more on the event communication system, the location abstraction layer and the other Gear functionalities.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/801021240915912006-3328120886345584663?l=digitalapes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://digitalapes.blogspot.com/feeds/3328120886345584663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=801021240915912006&amp;postID=3328120886345584663' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/3328120886345584663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/3328120886345584663'/><link rel='alternate' type='text/html' href='http://digitalapes.blogspot.com/2008/09/developing-mobile-applications-using.html' title='Developing mobile applications using Gear episode 2: Start using gear widgets and events'/><author><name>Paolo</name><uri>http://www.blogger.com/profile/16172678310067045282</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1NfXJ8vxGrs/R4AzHLSp1yI/AAAAAAAAABI/QMrDFb_9KBw/S220/rastapal.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_1NfXJ8vxGrs/SMFAowmS_VI/AAAAAAAAAGg/lwRbqA63icU/s72-c/screenshots.gif' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-801021240915912006.post-7081041519672431164</id><published>2008-07-24T10:41:00.000+02:00</published><updated>2008-12-11T04:11:17.053+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WTK'/><category scheme='http://www.blogger.com/atom/ns#' term='J2Me'/><category scheme='http://www.blogger.com/atom/ns#' term='Tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='Gear'/><category scheme='http://www.blogger.com/atom/ns#' term='Eclipse'/><title type='text'>Developing mobile applications using Gear episode 1: Create the first empty application</title><content type='html'>This is the first episode of a series of tutorials about developing mobile applications in J2ME using &lt;a href="http://gearjmf.sourceforge.net/"&gt;Gear&lt;/a&gt; framework. This tutorial will cover the first steps required to start developing any J2ME applications with or without using the Gear framework, the next tutorials will be more focused on Gear based applications. Every step of the tutorial has been tested on Windows Vista/XP and Ubuntu Linux, if you want to develop using MacOS, due to the lack of official Sun emulator, you should try &lt;a href="http://www.mpowerplayr.com/"&gt;MPowerPlayer&lt;/a&gt; or &lt;a href="http://www.microemu.org/"&gt;MicroEmulator&lt;/a&gt; tutorials.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Step 1: Obtain the required software&lt;/span&gt;&lt;br /&gt;There are two IDEs suitable for J2ME development: Eclipse and NetBeans, this tutorial will cover the steps required to develop using Eclipse. The required software thus will be:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;  Eclipse IDE&lt;br /&gt;(&lt;a href="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/europa/winter/"&gt;Eclipse 3.3 Europa&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;  Sun Wireless Toolkit&lt;br /&gt;(&lt;a href="http://java.sun.com/products/sjwtoolkit/download.html"&gt;WTK 2.5.2&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;  EclipseME&lt;br /&gt;(&lt;a href="http://www.eclipseme.org/"&gt;EclipseME 1.7.9&lt;/a&gt;, update site: http://www.eclipseme.org/updates/)&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;  Gear framework&lt;br /&gt;(&lt;a href="http://sourceforge.net/project/showfiles.php?group_id=234344"&gt;Gear JMF 0.9.0&lt;/a&gt;)&lt;/li&gt;&lt;/ul&gt;Download Eclipse IDE and Sun WTK from the links above and install both on your system. Installing Eclipse requires simply to extract the compressed package downloaded from the Eclipse site in a folder, typically "c:\Programs" on Windows or "/opt" on Linux. The Wireless Toolkit has a self installing procedure that will ask the user the target installation directory, again the typical directories are "c:\Programs" and "/opt".&lt;br /&gt;If you plan to use Gear framework download the Gear jar and javadoc and put them in a directory of your choice (/opt in this tutorial).&lt;br /&gt;We'll assume that after this step you'll have an Eclipse and a WTK directory in either one of the two directories listed above and eventually Gear files in the directory "/opt".&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Step 2: Configure Eclipse and EclipseME &lt;/span&gt;&lt;br /&gt;Now that you have installed the basic software it is time to execute Eclipse and configure it to support J2ME development.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;First run Eclips and go to the plug in install section.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1NfXJ8vxGrs/SIhWR61x9gI/AAAAAAAAAEg/DgNh7tPNY6k/s1600-h/InstallPlugins.png"&gt;&lt;img style="cursor: pointer;" src="http://3.bp.blogspot.com/_1NfXJ8vxGrs/SIhWR61x9gI/AAAAAAAAAEg/DgNh7tPNY6k/s320/InstallPlugins.png" alt="" id="BLOGGER_PHOTO_ID_5226522233416054274" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Select "Search for new features to install", click "Next" and add a new remote site.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SIhXmsD0X-I/AAAAAAAAAEw/UYtjUMLL2oc/s1600-h/EclipseMERemoteSite.png"&gt;&lt;img style="cursor: pointer;" src="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SIhXmsD0X-I/AAAAAAAAAEw/UYtjUMLL2oc/s320/EclipseMERemoteSite.png" alt="" id="BLOGGER_PHOTO_ID_5226523689737281506" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Select finish and install the plugin.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1NfXJ8vxGrs/SIhYzliuFzI/AAAAAAAAAE4/KrSUz3kakoY/s1600-h/EclipseMEInstall.png"&gt;&lt;img style="cursor: pointer;" src="http://3.bp.blogspot.com/_1NfXJ8vxGrs/SIhYzliuFzI/AAAAAAAAAE4/KrSUz3kakoY/s320/EclipseMEInstall.png" alt="" id="BLOGGER_PHOTO_ID_5226525010837772082" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Go to the preferences dialog and enter the "J2ME" section.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SIhZVm0fHwI/AAAAAAAAAFA/kyaFFiJ2OJo/s1600-h/Preferences.png"&gt;&lt;img style="cursor: pointer;" src="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SIhZVm0fHwI/AAAAAAAAAFA/kyaFFiJ2OJo/s320/Preferences.png" alt="" id="BLOGGER_PHOTO_ID_5226525595296276226" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Enter the "Device Management" subsection, press the "Import" button, select the directory where you have installed the WTK before and press "Finish" button.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SIhaTQTsMYI/AAAAAAAAAFI/bxazIAJmiUU/s1600-h/WTKDevices.png"&gt;&lt;img style="cursor: pointer;" src="http://4.bp.blogspot.com/_1NfXJ8vxGrs/SIhaTQTsMYI/AAAAAAAAAFI/bxazIAJmiUU/s320/WTKDevices.png" alt="" id="BLOGGER_PHOTO_ID_5226526654405030274" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Now go to the "Java-&gt;Debug" section of the preferences and change the "Debugger timeout" value to 30000.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1NfXJ8vxGrs/SIha4KPcl4I/AAAAAAAAAFQ/Qu8w1G7aUsk/s1600-h/EclipseMEDebug.png"&gt;&lt;img style="cursor: pointer;" src="http://3.bp.blogspot.com/_1NfXJ8vxGrs/SIha4KPcl4I/AAAAAAAAAFQ/Qu8w1G7aUsk/s320/EclipseMEDebug.png" alt="" id="BLOGGER_PHOTO_ID_5226527288431777666" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;Now Eclipse is configured correctly to write, run and debug J2ME applications.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Step 3: Create an application and reference the Gear framework&lt;/span&gt;&lt;br /&gt;Now it is time to create an empty J2ME application.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Enter the Eclipse "New" menu and select "Other".&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1NfXJ8vxGrs/SIhdne1ux_I/AAAAAAAAAFY/xjiXUXKVx4k/s1600-h/New2JME.png"&gt;&lt;img style="cursor: pointer;" src="http://2.bp.blogspot.com/_1NfXJ8vxGrs/SIhdne1ux_I/AAAAAAAAAFY/xjiXUXKVx4k/s320/New2JME.png" alt="" id="BLOGGER_PHOTO_ID_5226530300438169586" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Now create a new J2ME midlet suite, enter the name&lt;br /&gt;and press Next until you find the "Java settings" screen.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1NfXJ8vxGrs/SIhewBqv2yI/AAAAAAAAAFg/k7p1ETIGNXY/s1600-h/NewJ2ME_2.png"&gt;&lt;img style="cursor: pointer;" src="http://2.bp.blogspot.com/_1NfXJ8vxGrs/SIhewBqv2yI/AAAAAAAAAFg/k7p1ETIGNXY/s320/NewJ2ME_2.png" alt="" id="BLOGGER_PHOTO_ID_5226531546737924898" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;The following steps are optional, if you don't want to use the Gear framework just press "Finish".&lt;ul&gt;&lt;li&gt;Select the "Libraries" tab, press the "Add External JARs..." button and select the Gear jar file from the directory where you saved it.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SIhg7V79XgI/AAAAAAAAAFo/Z-5V3OUtaoU/s1600-h/GearFramework.png"&gt;&lt;img style="cursor: pointer;" src="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SIhg7V79XgI/AAAAAAAAAFo/Z-5V3OUtaoU/s320/GearFramework.png" alt="" id="BLOGGER_PHOTO_ID_5226533940180639234" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Add JavaDoc to Gear: click "javadoc location" sub menu and press the "Edit" button.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1NfXJ8vxGrs/SIhh7KZ40hI/AAAAAAAAAFw/ffFJgMVFjOs/s1600-h/GearFrameworkJavaDoc.png"&gt;&lt;img style="cursor: pointer;" src="http://3.bp.blogspot.com/_1NfXJ8vxGrs/SIhh7KZ40hI/AAAAAAAAAFw/ffFJgMVFjOs/s320/GearFrameworkJavaDoc.png" alt="" id="BLOGGER_PHOTO_ID_5226535036596572690" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Select Gear to be deployed within your application: enter the "Order and Export" tab, and click on Gear check box.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SIhikhrs2aI/AAAAAAAAAF4/uDGBU41rIkI/s1600-h/GearFrameworkExport.png"&gt;&lt;img style="cursor: pointer;" src="http://1.bp.blogspot.com/_1NfXJ8vxGrs/SIhikhrs2aI/AAAAAAAAAF4/uDGBU41rIkI/s320/GearFrameworkExport.png" alt="" id="BLOGGER_PHOTO_ID_5226535747219937698" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;Now simply press the "Finish" button and you'll be ready to start programming your J2ME application.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Conclusions&lt;/span&gt;&lt;br /&gt;The midlet suite we have created, is now ready to be filled with a set of midlets and all your application classes. In the next tutorials we'll describe how to create the midlets, how to display an interface, how to andle user's input and much more.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/801021240915912006-7081041519672431164?l=digitalapes.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://digitalapes.blogspot.com/feeds/7081041519672431164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=801021240915912006&amp;postID=7081041519672431164' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/7081041519672431164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/801021240915912006/posts/default/7081041519672431164'/><link rel='alternate' type='text/html' href='http://digitalapes.blogspot.com/2008/07/developing-mobile-applications-using.html' title='Developing mobile applications using Gear episode 1: Create the first empty application'/><author><name>Paolo</name><uri>http://www.blogger.com/profile/16172678310067045282</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1NfXJ8vxGrs/R4AzHLSp1yI/AAAAAAAAABI/QMrDFb_9KBw/S220/rastapal.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1NfXJ8vxGrs/SIhWR61x9gI/AAAAAAAAAEg/DgNh7tPNY6k/s72-c/InstallPlugins.png' height='72' width='72'/><thr:total>1</thr:total></entry></feed>
