• 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

JFileChooser - How to set imput focus.

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using JFileChooser to select files that already exist. I'd like the imput focus to be on the displayed list of files so that the user may immediately select one of more of the listed files but when the filechooser is displayed the input focus is in the text box. How may the input focus be specified?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you may need to explain this a bit more, as-is it makes little sense to me.

if I open a fileChooser with a list of files displayed to select from,
I'll use the mouse to select those file/s, so the focus could be anywhere
and it won't make any difference once I click on the first file
 
Nate Lockwood
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:
if I open a fileChooser with a list of files displayed to select from,
I'll use the mouse to select those file/s, so the focus could be anywhere
and it won't make any difference once I click on the first file



The user will NEVER type in a file name but will probably want to click on a file or select multiple files. The first file is automatically selected and I'd like to skip that first mouse click. The app will work without it but it's a small attention to detail.
 
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
this seems to be an unresolved issue with fileChoosers.

you can set it so the textfield (showing selected file) cannot have the focus,
but focus then goes to the look-in comboBox, so that's no good for you.

you may need to dig into the fileChooser source code to find the component
that displays the folder/file names (I think it's a JTable) and set the selection
of the automatically-selected first file
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also you could load all of the files into a JComboBox that way they have to choose from the list?
 
I can't beleive you just said that. Now I need to calm down with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic