• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Any one Can help me with Focus system?

 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am just trying to make a login form for my application which has username text field and password text field. the application is a touch screen application, so I am just planning to make a on screen key board with login form in the same screen something like the attched picture

My problem is: how to define action listener for each button. I don't have any idea at all.

if someone can help me please, I would appreciate it

Thnx


Picture1.png
[Thumbnail for Picture1.png]
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recommended reading: http://download.oracle.com/javase/tutorial/uiswing/events/actionlistener.html

You might want to edit your post title, as it is inconsistent and a bit misleading with the actual question.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Manish

Many Thanks for the Link, I know about action listeners and I know how to prgram the fuctions for a button, when you click on it.

the problems is with the focus on component. for example all I know is: when you click on a button it does TextField1.setText = button.getText() some thing like this.

the problem is I want the text to be writen in a textField where the cursor is. not to mention the name of textfields. like textfield.setText ..................

thanks for replying, but I think the title matchs my problem, which is focusing and sending the buttons text to the focused point.

Cheers
Farhad
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Manish

Manish Maneesh

the problem is I want the text to be writen in a textField where the cursor is. not to mention the name of textfields. like textfield.setText ..................

textField.setText(textField.getText()+charToBeWritten()) where char to be written would depend on which button the user pressed.

but I think the title matchs my problem, which is focusing and sending the buttons text to the focused point.

Not really. Your title is
Any one Can help me with Focus system?
, whereas, in your post you asked
My problem is: how to define action listener for each button. I don't have any idea at all.



 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Farhad Rahmati wrote:the problem is I want the text to be writen in a textField where the cursor is.


Then keep an instance variable whose type is JTextField. Any time a JTextField gets the focus, assign a reference to that JTextField to your instance variable. That way it will always point to the last text field which had the focus.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javax.swing.text.TextAction#getTextComponent(java.awt.event.ActionEvent)

Note that the ActionEvent can be null.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Maneesh,

I will let you know, if I had any other problem regarding this issue
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Thank you very much for your comments and your helps.

Specially Darryl Burke and Paul Clapham

I have tried both, I could manage to do it with Paul's comment. But I couldn't do that with TextAction.getTextComponent. I wish could do it, that's what I need

Becuase the method getTextComponent is protected and I could not find a way to use. I hope to do so.

if you guys have any idea please let me know.

but still it's working only in one window, but I want the on screen key board in a separat window not focusable. becuase I want the cursor should be in the focused TextBox. when you click the button in the On Screen Key Board Window. the should be writen in the text box where the cursor is in a different without. (SOMETHING LIKE WINDOWS SCREEN KEYBOARD)

Thanks again Paul and Darryl for your help, I appriciate
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic