frayab
frayab

Reputation: 2512

Lwuit: Use of PeerComponent

I want to use a PeerComponent in my Lwuit application for using a native Blackberry Field like this example:

Player player = Manager.createPlayer("capture://video");
player.realize();
VideoControl vc = (VideoControl) player.getControl("VideoControl");
Field viewFinder = (Field) vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
player.start();

My problem is that my project is java-me (not Blackberry). Using a native RIM component don't compile my project. I need differentiate cases between Blackberry devices and other Java devices and in Blackberry case use a Field, How can I do? It's possible with a PeerComponent?

Upvotes: 2

Views: 190

Answers (1)

Shai Almog
Shai Almog

Reputation: 52770

If you are using the new project structure generated by the GUI builder or manually as is done in the resource editor this should be very easy. In the new project structure the code of your application resides in a portable J2ME library project, the RIM/J2ME/J2SE/Android specific code resides in a separate project that just includes the library.

Once you do that you can define an interface to invoke a generic interface which you just implement differently for the platform specific code.

Alternatively you can always use a pre-processor and targets such as Netbeans allows, I understand Eclipse's mobile plugin has a similar facility as well.

Upvotes: 3

Related Questions