Skip to content

Commit b83345a

Browse files
committed
GUI added
1 parent bee89ba commit b83345a

8 files changed

Lines changed: 618 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package GUI.controller;
2+
3+
import java.net.URL;
4+
import java.util.ResourceBundle;
5+
6+
import GUI.utilities.Module;
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+
14+
import javafx.scene.control.TextField;
15+
import javafx.scene.control.cell.PropertyValueFactory;
16+
import javafx.scene.control.Label;
17+
18+
import javafx.scene.control.ComboBox;
19+
20+
import javafx.scene.image.ImageView;
21+
22+
import javafx.scene.input.MouseEvent;
23+
24+
import javafx.scene.control.TableView;
25+
26+
import javafx.scene.control.TableColumn;
27+
28+
public class ModuleController implements Initializable{
29+
@FXML private TextField txtSearchBar;
30+
@FXML private Button btnGo;
31+
32+
@FXML private TableView<Module>moduleTable;
33+
@FXML private TableColumn<Module, Integer>noofUnits;
34+
@FXML private TableColumn<Module, String>moduleName;
35+
36+
@FXML private ComboBox cmbDateRegistered;
37+
@FXML private ComboBox cmbCategory;
38+
@FXML private Label lblStudentName;
39+
@FXML private ImageView imgStudentImage;
40+
@FXML private TextField txtmoduleName;
41+
@FXML private TextField txtCost;
42+
@FXML
43+
private TextField txtPaid;
44+
@FXML
45+
private TextField txtDateCreated;
46+
@FXML
47+
private TextField txtNoofUnits;
48+
@FXML
49+
private Label lblBooked;
50+
@FXML
51+
private Label lblPaid;
52+
@FXML
53+
private Label lblRegistered;
54+
@FXML
55+
private Label lblAttended;
56+
@FXML
57+
private Label lblPassed;
58+
@FXML
59+
private Label lblFailed;
60+
61+
public ObservableList<Module> list = FXCollections.observableArrayList(
62+
new Module(10,"Electrical Installations"),
63+
new Module(3,"Digital Tech"),
64+
new Module(8,"MMF"),
65+
new Module(11,"basic Elect"),
66+
new Module(12,"Ethics")
67+
);
68+
69+
70+
71+
// Event Listener on TableView[#studentTable].onMouseClicked
72+
@FXML
73+
public void getDetails(MouseEvent event) {
74+
Module mod = (Module)moduleTable.getSelectionModel().getSelectedItem();
75+
txtmoduleName.setText(String.valueOf(mod.getModuleName()));
76+
txtNoofUnits.setText(String.valueOf(mod.getNoofUnits()));
77+
txtCost.setText("800");
78+
lblBooked.setText(String.valueOf(Math.round(Math.random()*100)));
79+
lblPaid.setText(String.valueOf(Math.round(Math.random()*100)));
80+
lblRegistered.setText(String.valueOf(Math.round(Math.random()*100)));
81+
lblAttended.setText(String.valueOf(Math.round(Math.random()*100)));
82+
}
83+
84+
@Override
85+
public void initialize(URL arg0, ResourceBundle arg1) {
86+
noofUnits.setCellValueFactory(new PropertyValueFactory<Module, Integer>("noofUnits"));
87+
moduleName.setCellValueFactory(new PropertyValueFactory<Module, String>("moduleName"));
88+
moduleTable.setItems(list);
89+
}
90+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package GUI.utilities;
2+
3+
import javafx.beans.property.SimpleIntegerProperty;
4+
import javafx.beans.property.SimpleStringProperty;
5+
6+
public class Module {
7+
private final SimpleIntegerProperty noofUnits;
8+
private final SimpleStringProperty moduleName;
9+
10+
public Module(Integer noofUnits, String moduleName) {
11+
super();
12+
this.noofUnits = new SimpleIntegerProperty(noofUnits);
13+
this.moduleName =new SimpleStringProperty(moduleName);
14+
}
15+
public Integer getNoofUnits() {
16+
return noofUnits.get();
17+
}
18+
public String getModuleName() {
19+
return moduleName.get();
20+
}
21+
22+
}//end class
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package GUI.utilities;
2+
3+
import javafx.beans.property.SimpleIntegerProperty;
4+
import javafx.beans.property.SimpleStringProperty;
5+
6+
public class Student {
7+
private final SimpleIntegerProperty id;
8+
private final SimpleStringProperty firstName;
9+
private final SimpleStringProperty lastName;
10+
11+
public Student(Integer id, String firstname, String lastname) {
12+
super();
13+
this.id = new SimpleIntegerProperty(id);
14+
this.firstName =new SimpleStringProperty(firstname);
15+
this.lastName = new SimpleStringProperty(lastname);
16+
}
17+
public Integer getId() {
18+
return id.get();
19+
}
20+
public String getFirstName() {
21+
return firstName.get();
22+
}
23+
public String getLastName() {
24+
return lastName.get();
25+
}
26+
27+
}//end class
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package GUI.utilities;
2+
3+
import javafx.application.Application;
4+
import javafx.fxml.FXMLLoader;
5+
import javafx.scene.Parent;
6+
import javafx.scene.Scene;
7+
import javafx.stage.Stage;
8+
9+
10+
public class TestGUI extends Application {
11+
12+
@Override
13+
public void start(Stage primaryStage) {
14+
try {
15+
//Parent root = FXMLLoader.load(getClass().getResource("/GUI/views/Module.fxml"));
16+
Parent root = FXMLLoader.load(getClass().getResource("/GUI/views/Student.fxml"));
17+
Scene scene = new Scene(root);
18+
primaryStage.setScene(scene);
19+
primaryStage.show();
20+
primaryStage.setTitle("Student");
21+
} catch(Exception e) {
22+
e.printStackTrace();
23+
}
24+
}
25+
26+
public static void main(String[] args) {
27+
launch(args);
28+
}
29+
}

0 commit comments

Comments
 (0)