title: How to populate the combobox by keeping the details in properties file
body: <p>How to populate the combobox by keeping the details in properties file..very much confused</p>
  
  <pre><code>static void config(String component, String environment) {     //Function for config file
  
      Properties prop = new Properties();
      InputStream input = null;
  
      try {
  
  
  
          input = new FileInputStream("C://Users//");
          prop.load(input);                                  // load a properties file
          Set&lt;Object&gt; keys = prop.keySet();
          String    key;
          Iterator&lt;Object&gt; iter = keys.iterator();
  
  
          while (iter.hasNext()) {
              key = (String) iter.next();
  
              System.out.println("Key: " + key);
  
              if (key.equals(component + "." + "basefilename")) 
              {
                  filename = prop.getProperty(key);
              }
  
              if (key.startsWith(component + "." + environment + "." + "url"))
              {
                  urls.add(prop.getProperty(key));
              }
  
          }
  
          System.out.println("Config Values");
          System.out.println("     Filename:" + filename);
          System.out.println("  URL's   :" +    urls.toString());
  
      } catch (IOException ex) {
          ex.printStackTrace();
      } finally {
          if (input != null) {
              try {
                  input.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      } 
  
  }
  
  static Hashtable&lt;String, String&gt; Validation() {   //function for UI    details
  
      {
          Hashtable&lt;String, String&gt; logininformation = new    Hashtable&lt;String, String&gt;();
  
          JPanel panel = new JPanel(new BorderLayout(5, 5));   //UI Creation
          JPanel label = new JPanel(new GridLayout(0, 1, 2, 2));
          label.add(new JLabel("User", SwingConstants.RIGHT));
          label.add(new JLabel("Password", SwingConstants.RIGHT));
          label.add(new JLabel("Component", SwingConstants.RIGHT));
          label.add(new JLabel("Environment", SwingConstants.RIGHT));
          panel.add(label, BorderLayout.WEST);
  
          JPanel controls = new JPanel(new GridLayout(0, 1, 2, 2));
          JTextField username = new JTextField();
          controls.add(username);
          JPasswordField password = new JPasswordField();
          controls.add(password);
  
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          ***String[] Componentstrings = { "dog", "lion", "tiger",    "elephant", };                //components
          String[]    Environmentstrings = { "Produktiv", "prelife","};     //environments
          ***these contents to be in properties file and to be    populated during execution**
          @SuppressWarnings("unchecked")
          JComboBox componentList = new JComboBox(Componentstrings);   //combo box for components
          controls.add(componentList);
          panel.add(controls,    BorderLayout.CENTER);
  
          @SuppressWarnings("unchecked")
          JComboBox EnvironmentList = new    JComboBox(Environmentstrings);   //combo box for environments
          controls.add(EnvironmentList);
          panel.add(controls,    BorderLayout.CENTER);
  
          Component frame1 = null;
          JOptionPane.showMessageDialog(frame1,    panel, "login", JOptionPane.QUESTION_MESSAGE);
  
          logininformation.put("user", username.getText());
          logininformation.put("pass", new String(password.getPassword()));
          logininformation.put("component", (String)    componentList.getSelectedItem());
          logininformation.put("environment", (String)    EnvironmentList.getSelectedItem());
  
          System.out.println("UI values:" + logininformation);
  
          return logininformation;
  
      }
  }
  </code></pre>