how to add background in j2me - java-me

Now I am developing a mobile application, I have developed menu by Canvas and I get stuck when I try to add background into application.
It means that I need to add background into my application and menu can visible on this background.
I am trying to find the way to add background into j2me, and I use array for menu and I found an example about adding background in J2me using TiledLayer and Layermanager, therefore that I just add these objects into my code for test.
Can it become a background in my code? I can not make it work that way

add background in J2me used TiledLayer and Layermanager
given above, first of all consider using GameCanvas instead of Canvas
public class MainMenu extends GameCanvas //...
Studying some introductory tutorials wouldn't hurt either:
Exploring the Game API of MIDP 2.0
Getting Started With the MIDP 2.0 Game API
By the way both above tutorials provide detailed explanations how to use TiledLayer and LayerManager for adding background

Related

Access to GTK4 Widgets in C Using Gnome Builder

I'm fairly new to coding for Linux, and haven't done a lot of GUI programming. I've run into problems using Gnome Builder and programmatic access to UI widgets.
How the heck to you access a widget (built in a UI file and instantiated by widget templates in the *-window.c source file) to do anything with the widget? I could use gtk_builder calls in GTK3 to access widgets, but the GTK4 model is completely different, and I haven't found useful information that describes or demonstrates how to do it.
There are 2 ways of doing this in GTK (both 3 and 4) with UI files:
Parse the UI definition using something like gtk_builder_new_from_resource(). You can then use API like gtk_builder_get_object() to fetch the widgets you want by their id attribute
Use composite templates like gtk_widget_class_bind_template_child(). You can find an example of how to do this in the second chapter of the GNOME beginners tutorial
Usually, the second option is preferred, as it tends to lead to less boilerplate code

TextEdit/TextBox onKey events in J2me

I'm developing (or trying to) a J2ME application. I need to be able to handle onKeyEvents (keyDown/keyPressed/keyUp...) in TextEdit/TextBoxes, but I've learned that such thing is not possible in J2me, at least not in a simple way as in Java/Android development (myEdit.setOnKeyListener() for example). I've read something about using Canvas, but I'm not sure how can I use that to make it work for me.
Answer to this question ( Image in button - j2me ) involves using the CustomItem class and make an item look/act like a Button. Is there anyway to use the same approach?
The TextBox and TextField objects are high-level GUI stuff, available when doing javax.microedition.lcdui.Form stuff.
In order to use keyPressed() and keyReleased() you must use javax.microedition.lcdui.Canvas (low-level GUI stuff).
But what you're probably really after, is LWUIT (https://lwuit.java.net). It is a framework built on javax.microedition.lcdui.Canvas which gives you a Form-like API with all the things javax.microedition.lcdui.Form is missing.

how to add canvas to the background of a form in j2me

I am new to j2me. I am developing a mobile application in j2me. Is there a way of adding a canvas object to the background of a form? I tried searching in net with few people suggesting to use "jmepolish". I have no idea what jmepolish is..Is there a way to do this with normal j2me classes?
No there's no way to do this. A J2ME form has very limited levels of customisation.
In order to make a fancy looking form that looks exactly as you want, you need to use the Canvas class; this involves doing everything else yourself, i.e. drawing your own input widgets, managing your own user interaction, including scrolling, and any touch screen/gesture stuff if your device supports it.
You can use libraries like J2ME Polish that will do that for you, but even then you will be constrained by what that library supports; and there is an overhead for including the library in your midlet.

Showing a UIWebView in Cocos2d 2.x project

I'd like to display a UIWebView within a CCLayer for a Cocos2d 2.x project. I found the CCUIViewWrapper, but didn't get it to work with 2.x.
I don't really care about handling rotation and animation. I just wan't to display content from a web page on layer and also have a sprite to be able to go back to the previous scene.
Please help!
// Johan
If you don't want to use new version 2.0 features (I'm not using them myself at this point), then you can mix UIViews with Cocos by simply adding other views to your root view controller. After all, Cocos is itself a single view on the controller (if that's how you have it set up), and just add another view.
You can then easily tell the view controller to show the other UIViews by using the NSNotificationCenter, which I recommend in general over trying to communicate with the view controller from the Cocos layer.

What is the best way to design the GUI in javafx 2.0?

In javafx 2.0 it is possible to create the layout by using FXML approach or by using normal java code.
What is the best way with respect to a well designed set of UIs. In my application there is about 100 sub UIs.
Thanks
FXML looks more logical for that purpose. By using FXML
you split business logic from view
you get option to edit design without recompiling project.
you get design as structured xml tree which is much easier to edit comparing to potentially randomly ordered java code
with SceneBuider tool you get an option to use visual editor for your fxml files
Get JavaFX Scenebuilder here.
FXForm2 is a library providing automatic JavaFX 2.0 form generation.
however FXForm2 is not full WYSIWYG GUI design tool.
http://dooapp.github.io/FXForm2/
Scene builder should be a good starting point to create unique UIs of your application. Considering you have 100s of UIs, I assume that some of their "appearances" should be identical with slightly different functions. You can load the FXML dynamically and assign controller at run time. Which means 1 FXML file can be used with multiple controllers. Which can save you some time while keeping the code dynamic for easier maintenance.
FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml"));
loader.setController(new DBeditEntityUser());
So, to make use of the same FXML with a different controller.
FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml"));
loader.setController(new DBeditEntityUserLevel());
Hope this helps.
fyi,
road map for Java fx http://javafx.com/roadmap/ shows that the scene builder will be released around middle of the year. From the above web page:
"JavaFX Scene Builder is a WYSIWYG GUI design tool for the
JavaFX platform. It enables designing user interface screens by simply
dragging and positioning GUI components from a palette onto a scene.
The tool generates files in FXML format2 that can be used within a project
in any IDE such as NetBeans or Eclipse. The JavaFX Scene Builder can be
used to create GUI for desktop applications and applets that run in a browser."

Resources