Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to set focus to password field in swings

 
angelin prema
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi


I have tried this.But still my password field is not getting the focus.
My class extends Jdialog.When i open it,i should get the cursor in this password field.
Please reply
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add a componentListener to oldPasswordField, and in componentShown put
oldPasswordField.requestFocusInWindow()
 
Pavan Kumar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After setVisible(true), you should use passowrField.requestFocusInWindow().




if your dialog is modal then the above doesn't work!! in such a case you must use this.


[ July 03, 2007: Message edited by: Pavan Kumar Mankala ]
 
angelin prema
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to add a component listener?
I have tried with this, but still didn't get.
oldPasswordField.setRequestFocusEnabled(true);
oldPasswordField.requestFocus();
oldPasswordField.requestFocusInWindow();
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> how to add a component listener?

http://java.sun.com/docs/books/tutorial/uiswing/events/componentlistener.html
 
angelin prema
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
This is my code.....
I need to set the cursor for oldpassword field while opening this window.
How can I get it?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where (in the 400+ lines of posted code) have you tried adding a componentListener?
 
angelin prema
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't create this code.just i am enhancing it.
I know basics of java alone.
I am new to MVC architecture.
Can you help me to set the focus in oldpassword field?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Can you help me to set the focus in oldpassword field?

I've already posted what to do, and a link that has examples of how to do it,
what problem do you still have?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!