Libellés

Affichage des articles dont le libellé est MIDlets. Afficher tous les articles
Affichage des articles dont le libellé est MIDlets. Afficher tous les articles

vendredi 27 mai 2011

Creating a Touch Enabled SVG UI for Java ME Devices

question here for you to test your mobile application in a touch screen. For this reason you need to enable this functionality in the configuration file for the device you use (in our example is the DefaultColorPhone). In this file option is marked FALSE touch_screen ... do not wait until I tell you to TRUE I think it makes sense.


After this change you can test your application. In our case it is a simple application (and unnecessary) that is achieved with the ease of svg included in this NetBeans User Interface. You can notice that the cross walk on the screen? That is, in fact this is cross your finger or that of the user, so you can test your application.

[The application (simple and useless) consist to write a text in the field provided and press the button with your finger so that the label is set to take down the text]


Enjoy!


dimanche 22 mai 2011

DATABINDING, WEB SERVICE and NETBEANS IDE

 DataBinding, Web Services and NetBeans 6.7

Prerequis Prerequisites
  - JavaME
- Netbeans Visual Mobile Designer Tool
- Netbeans Web Service Client Wizard tool

databinding Component
The element of NetBeans 6.7 IDE databinding is an easy to use tools to link these variables so that their changes be synchronous.  It will produce an architecture of data link in your MIDlet and everything you have to do is to specify who is linked with that and that operations will take place on the variables.

  The web service
In this tutorial we'll use databinding to display information from a previously created web service with Netbeans IDE. Our web service is just happy to tell you .... hello.(We'll keep it simple is the principle that counts). and our mobile application allows you to provide your name as parameter web service. A variable will be bound (databinding) to these various transactions and update the result of web service whenever you provide a new setting.
This is an example that you can just enter the operating mode of the tool databinding this in Netbeans.

  -> Create a new web project -> select a server (eg tomcat) -> Once you create the project done right click on the node -> choose new file -> web service
-> A file is created -> click on the small bulb notified by Netbeans and add a task to your web service.
Here is my final code example:
------------------------------------------------------------------------------------------------------ -------------------------------------------------- -------------------------------------------------- -
public class bonjourWS {

@WebMethod(operationName = "getMyPass")
public String operation(@WebParam(name = "nomParam")
String nomParam) {

return"Bonjour "+nomParam;
}
}
Right click on the file of your web service and test your web service.

JavaME client
 Use the Web service client JavaME netbeans wizard to generate a client in your mobile application. Right click on your mobile project -> web service client JavaME -> ....
After generating the code check if the stub was also generated if the file open. Wsclient that was generated and click "generate stubs"



 Application flow
With the tools Visual MIDlet design a simple flow like this
  
 Application screen
 Add the DataSet item to the palette in your application and add resources in two images in PNG format in the directory of your project.

Place items in the NetBeans palette as you see in the image below 
For the numbering here is what the work to be done:

1 -> right click -> property -> image -> databinding -> box and select dataSet [DataSet]
-> Enter in dataSet.photo EL Read "this just means that the term" picture "that will allow us to link the image to display to that of a variable with the ticket databinding.




2 -> right click -> property -> text -> databinding -> box and select dataSet [DataSet]
-> entrez dataSet.nom dans "EL Read" ceci signifie juste que c'est le terme "nom" qui nous permettra de lier le texte de cet champ à une variable par le billet du databinding. -> Enter in dataSet.nom EL Read "this just means that the term" name "that will allow us to link the text of the field to a variable with the ticket databinding. C'est sur ce champ de texte que nous utiliserons notre web service. It is on this text field that we will use our web service.



3 - As we did with the addition of the DataSet component in our project done on such a resource to add images in the code.

The application code
Go to the "Source" of the Visual Mobile Designer and add a declaration for an instance of the Stub class that you generate.  In my case it corresponds to the code:
 
-------------------------------------------------------------------------------------------------------------------------------------------
private bonjourWSService_Stub bews = new bonjourWSService_Stub();
-------------------------------------------------------------------------------------------------------------------------------------------

Locate the getValue method and adjust it by inserting a code similar to this one

------------------------------------------------------------------------------------------------------------------------------------------
public Object getValue(String name) throws IllegalStateException {

String a = choiceGroup.getString(choiceGroup.getSelectedIndex());

if (name.equals("nom")) {

/ * Note: The following clause if you use to specify what to do with the element of appointed dataSet.nom databinding * /

try {
/ / THIS IS OUR VERY SMALL CODE

return bews.getMyPass(a);
/ * Note: Bews is the subject of the Stub class we instantiated. just by typing "Bews." NetBeans offers a list of methods available for this purpose and among these methods it appears that our web service. . I call it so she and I pass a parameter value of the local variable "a". As you have noticed, a contains the value of field checked (name of the character chosen) * /
catch (RemoteException ex) {
ex.printStackTrace();
}
}
if (name.equals("photo")) {

  / * You can thanks to databinding to match that image to an image provided by a web service, but that's a matter aute .... */
}

}
return null;
} 
Test your application

 The application works fine now you are able to, efficiently handle the tool databinding in your applications to Netbeans mobile ... at least I hope so. Your suggessions are the property came.
[NOTE: The databinding as we have done will be done at application launch. To make it more dynamic set the command "validate" a method that will refresh the variables. Or you use two forms, one for the user's choice and one for displaying the result. .. ..  this tutorial is called to be improved at any time]
I just wanted to do so ...

dimanche 18 avril 2010

TESTER APPLICATION JAVAME POUR ECRAN TACTILE

il est question ici pour vous de tester votre application mobile dans un environnement à écran tactile. Pour cette raison vous devez activer cette fonctionnalités dans le fichier de configuration de la device que vous utilisez (Dans notre exemple c'est le defaultcolorphone). Dans ce fichier l'option touch_screen est marqué FALSE ... n'attendez pas que je vous dise de mettre TRUE je crois que c'est logique.
Après cette modification vous pouvez tester votre application. Dans notre cas il s'agit d'une application simple (et inutile) qui est réalisé avec les facilité du svg User Interface inclusent dans Netbeans. Vous pouvez remarquez la croix qui se balade sur l'écran ? Voilà, en fait cette croix c'est votre doigt ou celui de l'utilisateur, vous pouvez donc tester votre application.
[L'application simple et inutile consiste en fait à ecrire un texte dans le champ reservé et d'appuyer le bouton avec votre doigt pour que le label d'en bas prenne pour valeur ce texte]
Enjoy !

mercredi 14 avril 2010

lancer automatiquement MIDlet, Utiliser le Push Registry.

Le message d'origine à partir de: http://developers.sun.com/mobility/midp/questions/pushregistry/

Si vous voulez lancer automatiquement MIDlet, vous pouvez utiliser le Push Registry.

Comment faire?

La classe PushRegistry soutient un "push" modèle de distribution de contenu. Permettre à un MIDlet pour lancer en réponse à une connexion entrante ou à une heure programmée fait ensemble de nouvelles classes de services possible.

Spécification d'une entrée PushRegistry nécessite quatre éléments:

* Le MIDlet être lancé, spécifié à l'aide de l'attribut MIDlet-.

* Si la suite de MIDlets est signé, une demande autorisations, en utilisant l'attribut MIDlet-autorisations. La demande doit comprendre au moins la méthode javax.microedition.io.PushRegistry.

* Une connexion entrante URL, requis par le Connector.open () méthode.

* Un filtre pour les connexions entrantes. Le format du filtre est spécifique au protocole, mais le filtre "*" correspond à toute chaîne, et "?" correspond à tout caractère unique.

Une entrée PushRegistry peut être spécifiée soit dans une forme statique ou dynamique.

Une entrée statique PushRegistry est spécifié dans le descripteur d'application Java (JAD), le fichier manifeste, ou les deux. Le MIDlet, une fois installé, toujours répondre à la connexion spécifiée entrants. Ajouter le MIDlet, Push registre, et autorisations attribue à la JAD ou manifeste, comme dans cet exemple JAD:

MIDlet-1: CalPushHandler
MIDlet-Permissions: javax.microedition.io.PushRegistry,
javax.microedition.io.Connector.socket
MIDlet-Push-1: socket: / /: 5012, CalPushHandler, *


Ces paramètres seront la cause CalPushHandler MIDlet de lancer en réponse à une demande de connexion entrante sur le port 5012.

Une entrée dynamique PushRegistry est bien le même que une entrée statique sauf que vous utilisez le PushRegistry.registerConnection () pour spécifier le Push Entrée au lieu d'utiliser le MIDlet-Push- attribut. L'attribut MIDlet- est toujours nécessaire dans la JAD ou manifeste, comme c'est le MIDlet-autorisations d'attribut, dans le cas d'une suite MIDlet signé. Une entrée dynamique peut être activée (désactivée à l'aide et l'PushRegistry.unregisterConnection () méthode) après l'installation suite de MIDlets. Un exemple de fichier JAD devrait contenir:

MIDlet-1: CalPushHandler
MIDlet-Permissions: javax.microedition.io.PushRegistry,
javax.microedition.io.Connector.socket


Le code source MIDlet sont les suivantes:

...
javax.microedtion.io.PushRegistry d'importation;
...

String connURL = "socket: / /: 5012";
MIDletStr String = "CalPushHandler";
FilterStr String = "*";

try (
PushRegistry.registerConnection (connURL,
MIDletStr, FilterStr);
) Catch (ClassNotFoundException CNF) (
...
) Catch (IOException ioe) (
...
)
...


Utilisation des alarmes pour lancer MIDlets

Le PushRegistry.registerAlarm () méthode présente un MIDlet pour lancer à une heure programmée. Il est proche de UNIX à (1) l'installation. La méthode nécessite un MIDlet dans la série actuelle de lancer, avec un temps. Spécifiez le MIDlet comme une chaîne et l'époque comme un java.util.Date. Un échantillon suit.

Dans la JAD ou fichier manifeste, insérer:

MIDlet-1: AlarmMIDlet
MIDlet-Permissions: javax.microedition.io.PushRegistr


Dans le code source MIDlet comprennent:

...
javax.microedtion.io.PushRegistry d'importation;
...
prevalarm long;
MIDletname String = "AlarmMIDlet";
nexttime Date = java.util.Date nouvelle () + 60000;

prevalarm = PushRegistry.registerAlarm (MIDletname, nexttime);
...


La spécification MIDP 2.0 limite le nombre d'alarmes par MIDlet dans une suite à un.

Notez que la spécification n'exige pas mises en œuvre pour soutenir ces caractéristiques PushRegistry. S'ils ne sont pas pris en charge, une exception sera levée ConnectionNotFoundException.

Un exemple

La suite de MIDlets échantillon illustre l'utilisation d'une entrée statique PushRegistry et du PushRegistry.registerAlarm () méthode. Notez que la suite de MIDlets ne comprend pas les composants de l'interface.

La suite de MIDlets contient deux MIDlets et une autre classe. Le PushMIDlet prévoit un délai de journée (TSD) service (voir: Internet Engineering Task Force RFC 867) en utilisant la classe DayTimeServer. DayTimeServer implémente l'interface Runnable, l'exécution du service TSD dans un thread séparé. DayTimeServer ouvre la connexion au serveur, accepte la connexion entrante (l'événement qui a initié le lancement MIDlet en premier lieu), répond au client avec l'heure actuelle comme une chaîne, ferme les connexions, et des sorties. Dans l'ensemble, pas très excitant, mais indicatif et extensible.

Le PushMIDlet enregistre également la AlarmMIDlet d'exécution 60 secondes après la PushMIDlet est lancé. Le AlarmMIDlet simplement re-soi calendriers à l'aide PushRegistry.registerAlarm (). Le résultat est le lancement récurrent de la MIDlet, semblable à la cron UNIX (1M) installation. Le AlarmMIDlet peut être facilement étendu pour inclure des activités plus intéressantes à être exécutés périodiquement.

Conclusion

Les deux nouveaux mécanismes de lancement de MIDlet que le MIDP 2.0 classe PuhRegistry prévoit de rendre possible la création de services plus riches en contenu. Pour plus d'informations sur le bouton enregistrer, voir l'article Le Push Registry MIDP 2.0

Use Push Registry for automatically Launch a MIDlet

Original message from: http://developers.sun.com/mobility/midp/questions/pushregistry/

If you want to launch MIDlet automatically, you can use Push Registry.

How to do ?

The PushRegistry class supports a "push" model of content distribution. Enabling a MIDlet to launch in response to an incoming connection or at a scheduled time makes whole new classes of services possible.

Specifying a PushRegistry entry requires four items:

* The MIDlet to be launched, specified using the MIDlet- attribute.

* If the MIDlet suite is signed, a Permissions request, using the MIDlet-Permissions attribute. The request must include at least the javax.microedition.io.PushRegistry method.

* An inbound connection URL, required by the Connector.open() method.

* A filter for inbound connections. The format of the filter is protocol-specific, but the filter "*" matches any string, and "?" matches any single character.

A PushRegistry entry can be specified in either a static or dynamic form.

A static PushRegistry entry is specified in the Java Application Descriptor (JAD) file, the manifest file, or both. The MIDlet, once installed, will always respond to the specified incoming connection. Add the MIDlet, Push Registry, and Permissions attributes to the JAD or manifest, as in this example JAD file:

MIDlet-1 : CalPushHandler
MIDlet-Permissions : javax.microedition.io.PushRegistry,
javax.microedition.io.Connector.socket
MIDlet-Push-1 : socket://:5012, CalPushHandler, *


These settings will cause the MIDlet CalPushHandler to launch in response to an incoming connection request on port 5012.

A dynamic PushRegistry entry is much the same as a static entry except that you use the PushRegistry.registerConnection() method to specify the Push Entry instead of using the MIDlet-Push- attribute. The MIDlet- attribute is still required in the JAD or manifest, as is the MIDlet-Permissions attribute, in the case of a signed MIDlet suite. A dynamic entry can be enabled (and disabled using the PushRegistry.unregisterConnection() method) after MIDlet suite installation. An example JAD file would contain:

MIDlet-1 : CalPushHandler
MIDlet-Permissions : javax.microedition.io.PushRegistry,
javax.microedition.io.Connector.socket


The MIDlet source code would include:

...
import javax.microedtion.io.PushRegistry;
...

String connURL = "socket://:5012";
String MIDletStr = "CalPushHandler";
String FilterStr = "*";

try {
PushRegistry.registerConnection(connURL,
MIDletStr, FilterStr);
} catch ( ClassNotFoundException cnf ) {
...
} catch ( IOException ioe ) {
...
}
...


Using Alarms to Launch MIDlets

The PushRegistry.registerAlarm() method sets up a MIDlet to launch at a scheduled time. It's similar to the UNIX at(1) facility. The method requires a MIDlet within the current suite to launch, along with a time. Specify the MIDlet as a String and the time as a java.util.Date. A sample follows.

In the JAD or manifest file, insert:

MIDlet-1 : AlarmMIDlet
MIDlet-Permissions : javax.microedition.io.PushRegistr


In the MIDlet source code include:

...
import javax.microedtion.io.PushRegistry;
...
long prevalarm;
String MIDletname = "AlarmMIDlet";
Date nexttime = new java.util.Date() + 60000;

prevalarm = PushRegistry.registerAlarm( MIDletname, nexttime );
...


The MIDP 2.0 specification limits the number of alarms per MIDlet in a suite to one.

Note that the spec doesn't require implementations to support these PushRegistry features. If they're not supported, a ConnectionNotFoundException exception will be thrown.

An Example

The sample MIDlet suite illustrates use of a static PushRegistry entry and of the PushRegistry.registerAlarm() method. Note that the MIDlet suite does not include any UI components.

The MIDlet suite contains two MIDlets and one other class. The PushMIDlet provides a time-of-day (TOD) service (see: Internet Engineering Task Force RFC 867) using the DayTimeServer class. DayTimeServer implements the Runnable interface, executing the TOD service in a separate thread. DayTimeServer opens the server connection, accepts the incoming connection (the event that initiated the MIDlet launch in the first place), responds to the client with the current time as a string, closes the connections, and exits. All in all, not very exciting, but illustrative and extensible.

The PushMIDlet also registers the AlarmMIDlet for execution 60 seconds after the PushMIDlet is launched. The AlarmMIDlet merely re-schedules itself using PushRegistry.registerAlarm(). The result is recurring launch of the MIDlet, similar to the UNIX cron(1M) facility. The AlarmMIDlet can easily be extended to include more interesting activities to be executed periodically.

Conclusion

The two new MIDlet-launching mechanisms that the MIDP 2.0 PuhRegistry class provides make possible the creation of more content-rich services.

mercredi 5 août 2009

PIMP YOUR MOBILE SVG USER INTERFACE

PIMP YOUR MOBILE SVG USER INTERFACE

[sorry for english mistake]
About Netbeans and SVG
Netbeans IDE give you a simple way for using SVG API in your mobile application. By using SVG tool include in Netbeans IDE, SVG User Interface look very simple to be implemented. in fact Netbeans have two tools for doing that, SVG Components and SVG Form Components. But the design of these components may not satisfy you if you like high quality design. In this tutorial, I want to show you how you can add your own SVG component in Netbeans palette and use it in your application without any problem.

Make your SVG file out of Netbeans
You can find many SVG editor software on the web. For mobile designing you can use Ikivo animator or Mobile Designer Beatware like you can see in this image.

If you use Mobile Designer Beatware (I think it's the same for Ikivo) the simple thing you have to do is to drag and drop image on the work space and then convert that image to button by right clicking. After that you have to rename the "Button1" by "button_1". you have the possibility to animate your new button like you want. For example one of my button will grow when
the cursor move on.
[according to the software you use try to read the help for achieving this thanks]

Don't forget that when you will export your SVG file, the profile MUST BE SVG Tiny 1.1.
I have also made a simple SVG animation that i will add to Netbeans palette.
You can download the 2 SVG animation of this tutorial here.

-----LINK------

but.svg is the animation file for les button and gspirit.svg is the simple file logo's animation .

Work with Netbeans IDE
Put that two SVG files on your Netbeans mobile application project. Right Click the new SVG file node - copy - right click on the Netbeans palette - click palette manager - select Form components - right click - paste item. Your new item will appear. Now you can use it like all other Components deliver by Netbeans SVG Form Components palette.

Use visual Mobile Designer tool and add SVG Form item on your work space.
Now create new SVG file on your project. name it "formCustom.svg" Drag and drop the new SVG form component item that you have just add to palette.
Drag and drop the but.svg file project node on the Netbeans SVG editor space. Now you must have something like this.

Go to formCustom.svg file source code and everywhere you see
(x is an integer exemple: ) cut "id="button_x" and paste it at the end of tag. you must have this result:
-----------------------------------------------------------------------------------------------------------------------------------

<use x="-73" y="-50" xlink:href="#ipod.png"
transform="translate(-28.37,48.81) scale(0.625,0.65625)" id="button_1">
------------------------------------------------------------------------------------------------------------------------------------
Do it for all the three buttons.
now go to your Visual Mobile Designer file - drag and drop the formCustom.svg file over the SVG form item on your work space. If evrething is good you must see your new button be recognized by Netbeans IDE.

I have already write tutorial in this blog where i explain how to manipulate svg button. try to read this tutorial.
You can Run the project and see how your new SVG UI can be more attractive than UI which only use SVG elements present in Netbeans.

NOTE: You can do the same with the SVG menu component, then you will substitute "button_x" to "menu_x" ... something like this.
Give your comments and suggestions.
Thank for reading.