/* * Update radio button names in the same order as the table */ private void updateControlPanel() { schedule.removeAll(); noneButton.setName(""); // Name holds schedule id for the selected radio button noneButton.setSelected(true); commentTextArea.setText(""); // no text for the noneButton enableButtons(false); schedule.add(noneButton); schGroup.add(noneButton); for (int i = trainsScheduleModel.getFixedColumn(); i < trainsScheduleModel.getColumnCount(); i++) { log.debug("Column name: {}", trainsScheduleTable.getColumnName(i)); TrainSchedule ts = trainScheduleManager.getScheduleByName(trainsScheduleTable.getColumnName(i)); if (ts != null) { JRadioButton b = new JRadioButton(); b.setText(ts.getName()); b.setName(ts.getId()); schedule.add(b); schGroup.add(b); addRadioButtonAction(b); if (b.getName().equals(trainManager.getTrainScheduleActiveId())) { b.setSelected(true); enableButtons(true); // update comment field commentTextArea.setText(ts.getComment()); } } } schedule.revalidate(); }