public void displayTrain(int trainNumber) { this.trainNumber = trainNumber; trainViewJPanel1.display(trainNumber); String s; String destination = ""; int priority = TrainModel.PRIORITY_NORMAL; int state = TrainModel.STATE_STOPPED; if (trainNumber >= 0) { TrainModel train = (TrainModel) w.get(KEY.TRAINS, trainNumber, modelRoot.getPlayerPrincipal()); trainCargoBundleKey = train.getCargoBundle(); CargoBundle cb = (CargoBundle) w.get(train.getCargoBundle()); s = "Train #" + trainNumber + ": "; ScheduleIterator si = train.getScheduleIterator(); TrainOrdersModel tom = si.getCurrentOrder(w); if (tom != null) { ObjectKey2 ok = tom.getStation(); StationModel station = (StationModel) w.get(ok); destination = station.getStationName(); } priority = train.getPriority(); state = train.getState(); setStatusLabel(train); } else { s = "No trains to display"; setStatusLabel(null); } setStatusButton(priority, state); nameJLabel.setText(s); destinationJLabel.setText(destination); }