Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get # key when button is press?

 
Vincent Tan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

i'm developing a Midlet application using the netbeans IDE.
i facing some problem where if i want to key in # or * from the emulator, i just can't get it right.

1.when i press the button which have # key(because this button have #-+ and space together) what i always get is - or + or space.
how can i code it so that i can get to display the # key when i press on that button?

2.the other question is when developing a database application, is using RMS or JDBC better?
my application will deal with 1000++ data. can we apply JDBC into mobile phone?

3.How to know which button of the mobile phone is pressed? is using the "itemStateChanged" able to do this?
can you show me the example? what should i put in the "if" statement, if i want to capture the button of number 6 is pressed?
Some example i get it from internet.
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
//label.setVisible(true);
} else {
// label.setVisible(false);
}

Thanks.

 
Gopinath Karyadath
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
There is no key event in the TextBox.
you can use canvas for getting Key Event.

You can use only RMS for database connectivity.you cant use JDBC directly in device.


regards
 
Vincent Tan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Gopinath Karyadath,

Thanks for the answer.
i have try canvas in my midlet and it able to capture the keypress.
But this method is a bit troublesome as what i want to get is something like this:

at the emulator screen (when key is press)
________________________

888888#99#100*10
111111#99#100*10

________________________

if i want to display the above value, i have to store it into a string and repaint it when ever a key is press in order to show the string.
Is there a more simple way to do it?

the textbox with numeric type able to display number only but no the # and the *.
is there any other way?


 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vb EndUser welcome to JavaRanch , please check your private messages.
 
Pradeep Gudipati
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the TextField.ANY field and have a state listener whenever user enters a value the state changed will fire up, tell the user that the text field takes only numeric input.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic