示例#1
0
  private void fillFieldCars(JComboBox<String> cars) {
    String previousCar = null;

    for (Car car : shop.getCars()) {
      String carName = car.getManufacturer() + " " + car.getModel();
      if (!carName.equals(previousCar)) {
        cars.addItem(carName);
      }
      previousCar = carName;
    }
  }
示例#2
0
 private Car getCarFromStorage(JComboBox<String> cars, JComboBox<EngineKind> engine) {
   String carName = cars.getItemAt(cars.getSelectedIndex());
   Car car = null;
   for (Car carr : shop.getCars()) {
     if ((carr.getManufacturer() + " " + carr.getModel()).equals(carName)
         && carr.getEngineKind().equals(engine.getItemAt(engine.getSelectedIndex()))) {
       car = carr;
     }
   }
   return car;
 }