• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Visual Age for Java: requestFocus() doesn't work

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a simple application in Java Swing (created in VAJ 3.5) in which I have a JButton and a JTextField added to a JFrame.
When the application is run, the focus is on the JButton(by default).
I want the focus to be on the JTextField.
I have tried the following code(but it doesn't work) :
JTextField1().setRequestFocusEnabled(true);
JTextField1().requestFocus();
The same code works when I compile/execute it outside VAJ.
However suggestion to change the order of adding component to JFrame so that JTextField1 gets focus by default will not be helpful. Actually I want to implement requestFocus in an existing application with many JComponents.
Help please.
Sailesh
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic