• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to set focus to password field in swings

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
add a componentListener to oldPasswordField, and in componentShown put
oldPasswordField.requestFocusInWindow()
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic