コード例 #1
0
ファイル: ShopWindow.java プロジェクト: AlexRomanofff/Shop
  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
ファイル: ShopWindow.java プロジェクト: AlexRomanofff/Shop
 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;
 }