wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JComboBoxes and text files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBoxes and text files" Watch "JComboBoxes and text files" New topic
Author

JComboBoxes and text files

Steve Haggan
Greenhorn

Joined: Nov 03, 2012
Posts: 12
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

Joined: Oct 13, 2005
Posts: 37936
    
  22
You are sure you don’t want a Tree instead of multiple combo boxes?
Steve Haggan
Greenhorn

Joined: Nov 03, 2012
Posts: 12
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

Joined: Jun 13, 2009
Posts: 2152
    
    7
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JComboBoxes and text files
 
Similar Threads
drop down box using struts
i want some help in writing the code for the below description
Get Ready for Martin Fowler
Design a system to manage a sporting league
A point of sports etiquette