TextEdit/TextBox onKey events in J2me - java-me

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.

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

How to achieve Java.Lang.IRunnable in Xamarin iOS

I want to identify the scroll end action, which could not be achieved through the existing APIs from ScrollView. Because, when we scrolled fast, event after the pointer/hand is taken, certain scrolling is took place on its own. My requirement is to catch the point when the scrolling is ended on its own.
I can achieve this scenario in Xamarin.Android implementing Java.Lang.IRunnable in a custom class and by using the Run() method in it. I need to achieve this in Xamarin iOS.
Could you please provide a valid suggestion for this query ?
You can use "DecelerationEnded" event in UIScrollViewer to achieve your requirement.

How to perform ActionListener() in eclipse

Actually, I want to perform pure mouse actions(Clicking buttons, selecting check boxes, and select radio button)based upon the GUI label(name), But all the tutorials are given the example to perform with JFrame which we have created.
These examples makes me confusing.
Honestly I'm not professional developer. My professional is testing(QA), but I believe I have sufficient programming knowledge to understand the code. Please give me some sample that i can perform in eclipse IDE.
Note:
The objective of my question is:
How to perform the ActionEvent() in existed iDE?(The frame have File menu, Edit menu and so on.) Is it possible to do with Java?
Please share your ideas with me.
Thanks in advance.
Santhosh.
Create a frame.
Put a button into it.
Call the addActionListener class and add a ActionLister object
into it.
Override the actionPerformed method inside the anonymous inner
class.
As your question talks specifically about eclipse. You should use a plugin called window builder, built by google. It helps you handle action events.
Read the oracle's documentation for learning. http://docs.oracle.com/javase/tutorial/uiswing/components/button.html
I can't write all the code here. But just to get you started here's a link. http://www.javaprogrammingforums.com/java-swing-tutorials/278-how-add-actionlistener-jbutton-swing.html.

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.

how to add background in j2me

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

Resources