aspose file tools*
The moose likes Java Micro Edition and the fly likes Help on KeyPressed()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Help on KeyPressed()?" Watch "Help on KeyPressed()?" New topic
Author

Help on KeyPressed()?

Robin Thapa
Greenhorn

Joined: Aug 23, 2009
Posts: 11
Dear All,

I have two java classes here.

------------------------------------------------------------------------------------
Services.java


-----------------------------------------------------------------------------------
TCanvas.java


------------------------------------------------------------------------------------


The problem i have here is i can display the image but i have a problem to navigate through the images&text .ie in the emulator it displays (image and Text).
For eg in emulator i can see:
--------------------------------------
Services
About Us
Contact Us

Exit Show
-------------------------------------------
Now i want to use a keyPressed(int keyCode);
but how do i do that, coz my image is on canvas and im not being able to use the above keyPressed(int keyCode) method.

Please help me.

Robin Thapa


[Thumbnail for services.PNG]

Peter Miklosko
Ranch Hand

Joined: May 26, 2009
Posts: 76
When you start screen make one of the option highlighted-selected by default (draw rectangle with perhaps different colour then background and change style of text, bolder, different colour or font), have variable that holds a data on currently selected option. Create method for traverse and rest should be easy to finish once you know which option is selected.

PS: there is small difference on returned button press between emulator and real device. One return for example UP and the other Up. So watch out for these...
Robin Thapa
Greenhorn

Joined: Aug 23, 2009
Posts: 11
Peter Miklosko wrote:When you start screen make one of the option highlighted-selected by default (draw rectangle with perhaps different colour then background and change style of text, bolder, different colour or font), have variable that holds a data on currently selected option. Create method for traverse and rest should be easy to finish once you know which option is selected.

PS: there is small difference on returned button press between emulator and real device. One return for example UP and the other Up. So watch out for these...



Could you please just help me with my codes just to select the image? i mean can you help me to make a button kind of over those three......
Peter Miklosko
Ranch Hand

Joined: May 26, 2009
Posts: 76
Have look at this example, it is not pretty but it show how it can be done
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10266
    
    8

Robin,
In future, while posting code, please use code tags


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Robin Thapa
Greenhorn

Joined: Aug 23, 2009
Posts: 11
Peter Miklosko wrote:Have look at this example, it is not pretty but it show how it can be done


Dear Sir,

I am really thankful to you for your help and Support.
Robin Thapa
Greenhorn

Joined: Aug 23, 2009
Posts: 11
Dear Sir,

I have done it to some extend and im now able to navigate through the list.
I got into a small problem,

public void commandAction(Command c, Displayable d) {
if (c == backCommand) {
CanvasListMidlet.quitApp();
} else if (c == selectCommand) {
if (selectedIndex == 0) {
/// here i wish to call another canvas which consists of another List as in the examples class as:MessagesMenuScreen
// i tried calling another canvas class but i am not able to get it done.
// please help me

}
}
}


Your's
Robin Thapa
Robin Thapa
Greenhorn

Joined: Aug 23, 2009
Posts: 11
The above problem is actually sloved.

Thank you
Robin Thapa
Greenhorn

Joined: Aug 23, 2009
Posts: 11
Dear Sir,

Now i came into a big problem........... everything accomplished as i wanted.
But i read that we cannot create a textfield in a canvas.
So how do i accomplish it?
When user selects a list, i want them to enter something.
So how do i use a textfield in canvas?
or how can i create a textfield in canvas?please help me

Robin Thapa
Peter Miklosko
Ranch Hand

Joined: May 26, 2009
Posts: 76
Option A) Write your own TextField class that will be draw on Canvas (this is actually over kill, but if you think it would look better in your application then by any means do it)

Option B) On list selection redirect user to next screen with TextArea and collect user data and process them (returning back and showing them as part of list just in different font, decission is yours as I have no idea what you are up to)
Robin Thapa
Greenhorn

Joined: Aug 23, 2009
Posts: 11
Dear Sir,

My Project is a simple one.
I have to build the interface using canvas.
and almost all the interface is done, except when an menu item is clicked , it should display a textfield where a client can enter some inputs.

I have almost done it.

I did as you said in the earlier post.
Can i fill some color on the form so that the UI is inconsistency.

Please help me.
If you give me ure email id i would like to share my project with you.

Thanking you,

Robin Thapa

Dushyant Chhetri
Ranch Hand

Joined: Oct 28, 2009
Posts: 75
Hi Robin,

I would love to learn from your project
my email : dushdushyant@gmail.com

thanks in advance..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help on KeyPressed()?