• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JComboBoxes and text files

 
Steve Haggan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope someone can help me.
I have a number of files in a directory and they each contain a set of files.
It is based on the English Football league. So the Directory is leagues, then I have subfolders for the 4 leagues Prem, Championship etc, inside each subfolder are text files for each team containing details of the player stats in that team.
What I need to do is have two comboboxes - the first box will list the leagues and then the second box will be populated by the particular files in that subfolder (ie the user selects premier league the second combox box is populated by Arsenal, Man utd, Liverpool etc) the user can then pick a team and see the details of that team.
I can get the first combobox to read the divisions but I do not know how to get the second combobox to be populated dependant upon the choice made.
I have seen answers online using arrays but i do not wish to use them as I want to read it from files.
Would anyone have any ideas how I can proceed?

many thanks
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are sure you don’t want a Tree instead of multiple combo boxes?
 
Steve Haggan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You are sure you don’t want a Tree instead of multiple combo boxes?

I hear what you are saying.
A tree is likely to be easier but I think as I am using a GUI the drop down box will be more aesthetically pleasing and intuitive for a user.
 
Rob Camick
Ranch Hand
Posts: 2565
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen answers online using arrays but i do not wish to use them as I want to read it from files.


Then modify that code. Read text from a file is basic Java program.

When you use arrays you need a loop to create the array or read the data from the array. A File is no different you need a loop to read a line from the file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic