|
| 1 | +package GUI.controller; |
| 2 | + |
| 3 | + |
| 4 | +import java.net.URL; |
| 5 | +import java.util.ResourceBundle; |
| 6 | + |
| 7 | +import GUI.utilities.Student; |
| 8 | +import javafx.collections.FXCollections; |
| 9 | +import javafx.collections.ObservableList; |
| 10 | +import javafx.fxml.FXML; |
| 11 | +import javafx.fxml.Initializable; |
| 12 | +import javafx.scene.control.Button; |
| 13 | +import javafx.scene.control.ComboBox; |
| 14 | +import javafx.scene.control.Label; |
| 15 | +import javafx.scene.control.TableColumn; |
| 16 | +import javafx.scene.control.TableView; |
| 17 | +import javafx.scene.control.TextField; |
| 18 | +import javafx.scene.control.cell.PropertyValueFactory; |
| 19 | +import javafx.scene.image.ImageView; |
| 20 | + |
| 21 | +public class StudentController implements Initializable{ |
| 22 | + @FXML private TextField txtSearchBar; |
| 23 | + @FXML private Button btnGo; |
| 24 | + @FXML private ComboBox cmbDateRegistered; |
| 25 | + @FXML private ComboBox cmbCategory; |
| 26 | + @FXML private Label lblStudentName; |
| 27 | + @FXML private TextField txtBoxIdno; |
| 28 | + @FXML private TextField txtBoxfirstname; |
| 29 | + @FXML private TextField txtBoxlastname; |
| 30 | + @FXML private TextField txtBoxdateRegistered; |
| 31 | + @FXML private TextField txtBoxclassName; |
| 32 | + @FXML private TextField txtBoxDob; |
| 33 | + @FXML private TextField txtBoxphoneno; |
| 34 | + @FXML private ImageView imgStudentImage; |
| 35 | + @FXML private TableView moduleTable; |
| 36 | + @FXML private TableView<Student>studentTable; |
| 37 | + @FXML private TableColumn<Student, Integer>id; |
| 38 | + @FXML private TableColumn<Student, String>firstName; |
| 39 | + @FXML private TableColumn<Student, String>lastName; |
| 40 | + //private ObservableList<Student> list; |
| 41 | + |
| 42 | + public ObservableList<Student> list = FXCollections.observableArrayList( |
| 43 | + new Student(001,"john","willard"), |
| 44 | + new Student(011,"W.T","BAS"), |
| 45 | + new Student(021,"judge","Noose"), |
| 46 | + new Student(401,"williams","bukly"), |
| 47 | + new Student(301,"Row","Ark") |
| 48 | + ); |
| 49 | + |
| 50 | + |
| 51 | + @Override |
| 52 | + public void initialize(URL arg0, ResourceBundle arg1) { |
| 53 | + id.setCellValueFactory(new PropertyValueFactory<Student, Integer>("id")); |
| 54 | + firstName.setCellValueFactory(new PropertyValueFactory<Student, String>("firstName")); |
| 55 | + lastName.setCellValueFactory(new PropertyValueFactory<Student, String>("lastName")); |
| 56 | + studentTable.setItems(list); |
| 57 | + } |
| 58 | + |
| 59 | + public void getuser() { |
| 60 | + Student std = (Student)studentTable.getSelectionModel().getSelectedItem(); |
| 61 | + txtBoxIdno.setText(String.valueOf(std.getId())); |
| 62 | + txtBoxfirstname.setText(std.getFirstName()); |
| 63 | + txtBoxlastname.setText(std.getLastName()); |
| 64 | + |
| 65 | + } |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + /* |
| 71 | + * @FXML private TableView<CompetitorStatus>table; |
| 72 | + @FXML private TableColumn<CompetitorStatus, Integer>sn; |
| 73 | + @FXML private TableColumn<CompetitorStatus, String>competitorName; |
| 74 | + @FXML private TableColumn<CompetitorStatus, String>eliminated; |
| 75 | + |
| 76 | + @FXML private Label tourStage; |
| 77 | + private CommonMethods cm = new CommonMethods(); |
| 78 | + private Font font[] = new Font[3]; |
| 79 | + |
| 80 | + private Tournament tournament; |
| 81 | + private ObservableList<CompetitorStatus> list; |
| 82 | + |
| 83 | + public void initialize() { |
| 84 | + font = cm.loadfonts(); |
| 85 | +
|
| 86 | + tourStage.setFont(font[1]);// tournament Specs |
| 87 | + //tourStage.size |
| 88 | + } |
| 89 | + |
| 90 | + public void setTournament(Tournament tour) { |
| 91 | + tournament = tour; |
| 92 | + |
| 93 | + |
| 94 | + sn.setCellValueFactory(new PropertyValueFactory<CompetitorStatus, Integer>("sn")); |
| 95 | + competitorName.setCellValueFactory(new PropertyValueFactory<CompetitorStatus, String>("competitorName")); |
| 96 | + eliminated.setCellValueFactory(new PropertyValueFactory<CompetitorStatus, String>("eliminated")); |
| 97 | + |
| 98 | + table.setItems(setuptablevariable()); |
| 99 | + } |
| 100 | + |
| 101 | +
|
| 102 | + |
| 103 | + public ObservableList<CompetitorStatus> setuptablevariable() { |
| 104 | + list = FXCollections.observableArrayList(); |
| 105 | + Competitor comp[]; |
| 106 | + comp = tournament.getCompetitors(); |
| 107 | + for (int i = 0; i < comp.length; i++) { |
| 108 | + list.add(new CompetitorStatus(i+1,comp[i].getName(), (comp[i].isEliminated() ? "Yes" : "No"))); |
| 109 | + } |
| 110 | + return list; |
| 111 | + |
| 112 | + }//end utility method |
| 113 | + |
| 114 | + * |
| 115 | + * |
| 116 | + * */ |
| 117 | +} |
0 commit comments