Better UI, added LookAndFeel, changed fonts
This commit is contained in:
@@ -3,6 +3,7 @@ package org.lumijiez.gui.forms.faculty;
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.enums.StudyField;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -48,8 +49,9 @@ public class AddFacultyForm extends JFrame {
|
||||
enumList[i] = sfl.get(i).getName();
|
||||
|
||||
specialtyCombo.setModel(new DefaultComboBoxModel<>(enumList));
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
specialtyCombo.addActionListener(this::specialtyComboActionPerformed);
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
|
||||
@@ -7,7 +7,9 @@ package org.lumijiez.gui.forms.faculty;
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.enums.StudyField;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -52,8 +54,8 @@ public class EditFacultyForm extends JFrame {
|
||||
abbreviationField.setText("Abbreviation...");
|
||||
specialtyLabel.setText("New specialty:");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
@@ -62,14 +64,7 @@ public class EditFacultyForm extends JFrame {
|
||||
|
||||
specialtyCombo.setSelectedItem(((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem())).getField());
|
||||
|
||||
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Faculty)
|
||||
setText(((Faculty) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
|
||||
specialtyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
|
||||
@@ -6,10 +6,11 @@ package org.lumijiez.gui.forms.faculty;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class RemoveFacultyForm extends JFrame {
|
||||
@@ -40,20 +41,13 @@ public class RemoveFacultyForm extends JFrame {
|
||||
cancelButton.setText("Cancel");
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Faculty)
|
||||
setText(((Faculty) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -6,10 +6,11 @@ package org.lumijiez.gui.forms.faculty;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class ShowFacultyForm extends JFrame {
|
||||
@@ -40,21 +41,14 @@ public class ShowFacultyForm extends JFrame {
|
||||
cancelButton.setText("Cancel");
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
facultyCombo.addActionListener(this::facultyComboActionPerformed);
|
||||
|
||||
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Faculty)
|
||||
setText(((Faculty) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -7,9 +7,11 @@ package org.lumijiez.gui.forms.group;
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -44,20 +46,13 @@ public class AddGroupForm extends JFrame {
|
||||
nameLabel.setText("Name:");
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Faculty)
|
||||
setText(((Faculty) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -6,10 +6,11 @@ package org.lumijiez.gui.forms.group;
|
||||
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class DeleteGroupForm extends JFrame {
|
||||
@@ -39,20 +40,13 @@ public class DeleteGroupForm extends JFrame {
|
||||
cancelButton.setText("Cancel");
|
||||
groupLabel.setText("Group:");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Group)
|
||||
setText(((Group) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -7,10 +7,11 @@ package org.lumijiez.gui.forms.group;
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -40,6 +41,7 @@ public class EditGroupForm extends JFrame {
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Edit a group");
|
||||
nameField.setText("Name...");
|
||||
submitButton.setText("Submit");
|
||||
@@ -48,29 +50,14 @@ public class EditGroupForm extends JFrame {
|
||||
groupLabel.setText("Group:");
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Faculty)
|
||||
setText(((Faculty) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
|
||||
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Group)
|
||||
setText(((Group) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);;
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -6,10 +6,11 @@ package org.lumijiez.gui.forms.group;
|
||||
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -40,20 +41,13 @@ public class ShowGroupForm extends JFrame {
|
||||
cancelButton.setText("Cancel");
|
||||
submitButton.setText("Submit");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Group)
|
||||
setText(((Group) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -7,120 +7,113 @@ package org.lumijiez.gui.forms.student;
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AddStudentForm extends JFrame {
|
||||
Integer[] days = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||
Integer[] months = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
|
||||
Integer[] years = new Integer[100];
|
||||
private final Supervisor sv;
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final JComboBox<Group> groupCombo;
|
||||
private final JTextField nameField = new javax.swing.JTextField();
|
||||
private final JButton submitButton = new javax.swing.JButton();
|
||||
private final JButton cancelButton = new javax.swing.JButton();
|
||||
private final JLabel nameLabel = new javax.swing.JLabel();
|
||||
private final JTextField surnameField = new javax.swing.JTextField();
|
||||
private final JTextField emailField = new javax.swing.JTextField();
|
||||
private final JLabel surnameLabel = new javax.swing.JLabel();
|
||||
private final JLabel emailLabel = new javax.swing.JLabel();
|
||||
private final JComboBox<Faculty> facultyCombo;
|
||||
private final JLabel groupLabel = new javax.swing.JLabel();
|
||||
private final JLabel facultyLabel = new javax.swing.JLabel();
|
||||
private final JComboBox<Integer> birthYearField;
|
||||
private final JComboBox<Integer> birthDayField;
|
||||
private final JComboBox<Integer> birthMonthField;
|
||||
private final JLabel birthYearLabel = new javax.swing.JLabel();
|
||||
private final JLabel birthDayLabel = new javax.swing.JLabel();
|
||||
private final JLabel birthMonthLabel = new javax.swing.JLabel();
|
||||
private final JLabel enrolDayLabel = new javax.swing.JLabel();
|
||||
private final JComboBox<Integer> enrolDayField;
|
||||
private final JComboBox<Integer> enrolMonthField;
|
||||
private final JComboBox<Integer> enrolYearField;
|
||||
private final JLabel enrolMonthLabel = new javax.swing.JLabel();
|
||||
private final JLabel enrolYearLabel = new javax.swing.JLabel();
|
||||
private final JComboBox<Group> groupCombo = new JComboBox<>();
|
||||
private final JTextField nameField = new JTextField();
|
||||
private final JButton submitButton = new JButton();
|
||||
private final JButton cancelButton = new JButton();
|
||||
private final JLabel nameLabel = new JLabel();
|
||||
private final JTextField surnameField = new JTextField();
|
||||
private final JTextField emailField = new JTextField();
|
||||
private final JLabel surnameLabel = new JLabel();
|
||||
private final JLabel emailLabel = new JLabel();
|
||||
private final JComboBox<Faculty> facultyCombo = new JComboBox<>();
|
||||
private final JLabel groupLabel = new JLabel();
|
||||
private final JLabel facultyLabel = new JLabel();
|
||||
private final JComboBox<Integer> birthYearField = new JComboBox<>();
|
||||
private final JComboBox<Integer> birthDayField = new JComboBox<>();
|
||||
private final JComboBox<Integer> birthMonthField = new JComboBox<>();
|
||||
private final JLabel birthYearLabel = new JLabel();
|
||||
private final JLabel birthDayLabel = new JLabel();
|
||||
private final JLabel birthMonthLabel = new JLabel();
|
||||
private final JLabel enrolDayLabel = new JLabel();
|
||||
private final JComboBox<Integer> enrolDayField = new JComboBox<>();
|
||||
private final JComboBox<Integer> enrolMonthField = new JComboBox<>();
|
||||
private final JComboBox<Integer> enrolYearField = new JComboBox<>();
|
||||
private final JLabel enrolMonthLabel = new JLabel();
|
||||
private final JLabel enrolYearLabel = new JLabel();
|
||||
|
||||
public AddStudentForm(Supervisor sv) {
|
||||
for (int i = 0; i < 100; i++) years[i] = 1970 + i;
|
||||
this.sv = sv;
|
||||
birthDayField = new JComboBox<>(days);
|
||||
birthMonthField = new JComboBox<>(months);
|
||||
birthYearField = new JComboBox<>(years);
|
||||
enrolDayField = new JComboBox<>(days);
|
||||
enrolMonthField = new JComboBox<>(months);
|
||||
enrolYearField = new JComboBox<>(years);
|
||||
facultyCombo = new JComboBox<>(sv.getFm().getFaculties().toArray(new Faculty[0]));
|
||||
groupCombo = new JComboBox<>(sv.getFm().getGm().getGroups().toArray(new Group[0]));
|
||||
|
||||
Integer[] days = new Integer[31];
|
||||
for (int i = 0; i < 31; i++) {
|
||||
days[i] = i + 1;
|
||||
}
|
||||
|
||||
Integer[] months = new Integer[12];
|
||||
for (int i = 0; i < 12; i++) {
|
||||
months[i] = i + 1;
|
||||
}
|
||||
|
||||
Integer[] years = new Integer[100];
|
||||
for (int i = 0; i < 100; i++) {
|
||||
years[i] = 1970 + i;
|
||||
}
|
||||
|
||||
birthDayField.setModel(new DefaultComboBoxModel<>(days));
|
||||
birthMonthField.setModel(new DefaultComboBoxModel<>(months));
|
||||
birthYearField.setModel(new DefaultComboBoxModel<>(years));
|
||||
|
||||
enrolDayField.setModel(new DefaultComboBoxModel<>(days));
|
||||
enrolMonthField.setModel(new DefaultComboBoxModel<>(months));
|
||||
enrolYearField.setModel(new DefaultComboBoxModel<>(years));
|
||||
|
||||
facultyCombo.setModel(new DefaultComboBoxModel<>(sv.getFm().getFaculties().toArray(new Faculty[0])));
|
||||
groupCombo.setModel(new DefaultComboBoxModel<>(sv.getFm().getGm().getGroups().toArray(new Group[0])));
|
||||
|
||||
initComponents();
|
||||
}
|
||||
|
||||
|
||||
private void initComponents() {
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
|
||||
titleLabel.setText("Add a new student");
|
||||
|
||||
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Faculty)
|
||||
setText(((Faculty) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
|
||||
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Group)
|
||||
setText(((Group) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
submitButton.setText("Submit");
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
cancelButton.setText("Cancel");
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
nameLabel.setText("Name:");
|
||||
|
||||
surnameLabel.setText("Surname:");
|
||||
|
||||
emailLabel.setText("Email:");
|
||||
|
||||
groupLabel.setText("Group:");
|
||||
|
||||
facultyLabel.setText("Faculty:");
|
||||
|
||||
birthYearLabel.setText("Year of Birth:");
|
||||
|
||||
birthDayLabel.setText("Day of Birth:");
|
||||
|
||||
birthMonthLabel.setText("Month of Birth:");
|
||||
|
||||
enrolDayLabel.setText("Day of Enrollment:");
|
||||
|
||||
enrolMonthLabel.setText("Month of Enrollment:");
|
||||
|
||||
enrolYearLabel.setText("Year of Enrollment:");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(132, 132, 132)
|
||||
.addComponent(titleLabel))
|
||||
@@ -129,120 +122,120 @@ public class AddStudentForm extends JFrame {
|
||||
.addComponent(surnameLabel)
|
||||
.addGap(142, 142, 142)
|
||||
.addComponent(emailLabel)))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(21, 21, 21)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(surnameField, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(surnameField, GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
|
||||
.addComponent(nameField)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(5, 5, 5)
|
||||
.addComponent(nameLabel))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addComponent(birthDayField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(birthDayLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(birthMonthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(birthMonthLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(birthMonthField))))
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(groupLabel)
|
||||
.addGap(67, 67, 67)
|
||||
.addComponent(facultyLabel)
|
||||
.addGap(51, 51, 51))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(groupCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(34, 34, 34)
|
||||
.addComponent(facultyCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(cancelButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(submitButton))))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(32, 32, 32)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addComponent(birthYearLabel)
|
||||
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
.addComponent(birthYearField, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE))))
|
||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(enrolDayLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(enrolDayLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(enrolDayField))
|
||||
.addGap(29, 29, 29)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(enrolMonthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
|
||||
.addComponent(enrolMonthLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(enrolMonthField, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||
.addComponent(enrolMonthField, GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||
.addGap(55, 55, 55)))
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(enrolYearField, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||
.addComponent(enrolYearField, GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
|
||||
.addGap(43, 43, 43))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(enrolYearLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(enrolYearLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap()))))));
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(titleLabel)
|
||||
.addGap(13, 13, 13)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(nameLabel)
|
||||
.addComponent(groupLabel)
|
||||
.addComponent(facultyLabel))
|
||||
.addGap(3, 3, 3)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(groupCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(facultyCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(nameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(groupCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(facultyCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(11, 11, 11)
|
||||
.addComponent(surnameLabel)
|
||||
.addGap(5, 5, 5))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(emailLabel)
|
||||
.addGap(4, 4, 4)))
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(surnameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(emailField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(surnameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(emailField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(birthDayLabel)
|
||||
.addComponent(birthMonthLabel)
|
||||
.addComponent(birthYearLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(birthDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(birthMonthField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(birthYearField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(birthDayField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(birthMonthField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(birthYearField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(enrolDayLabel)
|
||||
.addComponent(enrolMonthLabel)
|
||||
.addComponent(enrolYearLabel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(enrolDayField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(enrolMonthField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(enrolYearField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(enrolDayField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(enrolMonthField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(enrolYearField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(36, 36, 36)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cancelButton)
|
||||
.addComponent(submitButton))
|
||||
.addGap(21, 21, 21)));
|
||||
@@ -257,36 +250,38 @@ public class AddStudentForm extends JFrame {
|
||||
String name = nameField.getText();
|
||||
String surname = surnameField.getText();
|
||||
String email = emailField.getText();
|
||||
Group group = (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||
Faculty faculty = ((Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem()));
|
||||
|
||||
int birthYear = (Integer) Objects.requireNonNull(birthYearField.getSelectedItem());
|
||||
int birthMonth = (Integer) Objects.requireNonNull(birthMonthField.getSelectedItem());
|
||||
int birthDay = (Integer) Objects.requireNonNull(birthDayField.getSelectedItem());
|
||||
int enrolYear = (Integer) Objects.requireNonNull(enrolYearField.getSelectedItem());
|
||||
int enrolMonth = (Integer) Objects.requireNonNull(enrolMonthField.getSelectedItem());
|
||||
int enrolDay = (Integer) Objects.requireNonNull(enrolDayField.getSelectedItem());
|
||||
Group group = getSelectedGroup();
|
||||
Faculty faculty = getSelectedFaculty();
|
||||
Date birthDate = getDateFromFields(birthYearField, birthMonthField, birthDayField);
|
||||
Date enrolDate = getDateFromFields(enrolYearField, enrolMonthField, enrolDayField);
|
||||
|
||||
if (!name.isEmpty() && !surname.isEmpty() && !email.isEmpty()) {
|
||||
Calendar birthCalendar = Calendar.getInstance();
|
||||
Calendar enrolCalendar = Calendar.getInstance();
|
||||
|
||||
birthCalendar.set(Calendar.YEAR, birthYear);
|
||||
birthCalendar.set(Calendar.MONTH, birthMonth - 1);
|
||||
birthCalendar.set(Calendar.DAY_OF_MONTH, birthDay);
|
||||
|
||||
enrolCalendar.set(Calendar.YEAR, enrolYear);
|
||||
enrolCalendar.set(Calendar.MONTH, enrolMonth - 1);
|
||||
enrolCalendar.set(Calendar.DAY_OF_MONTH, enrolDay);
|
||||
|
||||
Date birthDate = birthCalendar.getTime();
|
||||
Date enrolDate = enrolCalendar.getTime();
|
||||
sv.addStudent(name, surname, email, group, faculty, birthDate, enrolDate);
|
||||
|
||||
StudentManagementGUI.displayStudents();
|
||||
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private Group getSelectedGroup() {
|
||||
return (Group) Objects.requireNonNull(groupCombo.getSelectedItem());
|
||||
}
|
||||
|
||||
private Faculty getSelectedFaculty() {
|
||||
return (Faculty) Objects.requireNonNull(facultyCombo.getSelectedItem());
|
||||
}
|
||||
|
||||
private Date getDateFromFields(JComboBox<Integer> yearField, JComboBox<Integer> monthField, JComboBox<Integer> dayField) {
|
||||
int year = (Integer) Objects.requireNonNull(yearField.getSelectedItem());
|
||||
int month = (Integer) Objects.requireNonNull(monthField.getSelectedItem()) - 1;
|
||||
int day = (Integer) Objects.requireNonNull(dayField.getSelectedItem());
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, year);
|
||||
calendar.set(Calendar.MONTH, month);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, day);
|
||||
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@ package org.lumijiez.gui.forms.student;
|
||||
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -36,21 +37,14 @@ public class DeleteStudentForm extends JFrame {
|
||||
titleLabel.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setText("Delete Student");
|
||||
|
||||
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Student)
|
||||
setText(((Student) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
|
||||
studentLabel.setText("Student:");
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
@@ -8,13 +8,12 @@ import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
public class EditStudentForm extends JFrame {
|
||||
@@ -96,40 +95,16 @@ public class EditStudentForm extends JFrame {
|
||||
//
|
||||
// enrolYearLabel.setText("Year of Enrollment:");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
studentCombo.addActionListener(this::studentComboActionPerformed);
|
||||
|
||||
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Faculty)
|
||||
setText(((Faculty) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
|
||||
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Group)
|
||||
setText(((Group) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
|
||||
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Student)
|
||||
setText(((Student) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setFacultyRenderer(facultyCombo);;
|
||||
ComboBoxRenderers.setGroupRenderer(groupCombo);
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
|
||||
groupCombo.setSelectedItem(((Student)studentCombo.getSelectedItem()).getGroup());
|
||||
|
||||
|
||||
@@ -7,10 +7,11 @@ package org.lumijiez.gui.forms.student;
|
||||
import org.lumijiez.base.Grade;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.enums.Subjects;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -50,29 +51,14 @@ public class GradeStudentForm extends JFrame {
|
||||
gradeLabel.setText("Grade:");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Student)
|
||||
setText(((Student) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
|
||||
subjectCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Subjects)
|
||||
setText(((Subjects) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
ComboBoxRenderers.setSubjectRenderer(subjectCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -6,7 +6,9 @@ package org.lumijiez.gui.forms.student;
|
||||
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.StudentManagementGUI;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -36,14 +38,7 @@ public class GraduateStudentForm extends JFrame {
|
||||
titleLabel.setFont(new Font("sansserif", 0, 18)); // NOI18N
|
||||
titleLabel.setText("Graduate a Student");
|
||||
|
||||
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Student)
|
||||
setText(((Student) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
|
||||
studentLabel.setText("Student:");
|
||||
submitButton.setText("Submit");
|
||||
@@ -52,8 +47,8 @@ public class GraduateStudentForm extends JFrame {
|
||||
submitButton.setBackground(new Color(204, 255, 204));
|
||||
cancelButton.setBackground(new Color(255, 204, 204));
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
package org.lumijiez.gui.forms.student;
|
||||
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -40,20 +41,13 @@ public class ShowStudentForm extends JFrame {
|
||||
studentLabel.setText("Student:");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Student)
|
||||
setText(((Student) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -6,10 +6,11 @@ package org.lumijiez.gui.forms.student;
|
||||
|
||||
import org.lumijiez.base.Grade;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.gui.util.ComponentDecorator;
|
||||
import org.lumijiez.managers.Supervisor;
|
||||
import org.lumijiez.gui.util.ComboBoxRenderers;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -41,20 +42,13 @@ public class ShowStudentGradesForm extends JFrame {
|
||||
submitButton.setText("Submit");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
submitButton.setBackground(new java.awt.Color(204, 255, 204));
|
||||
cancelButton.setBackground(new java.awt.Color(255, 204, 204));
|
||||
ComponentDecorator.submitButton(submitButton);
|
||||
ComponentDecorator.cancelButton(cancelButton);
|
||||
|
||||
submitButton.addActionListener(this::submitButtonActionPerformed);
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
|
||||
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Student)
|
||||
setText(((Student) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
ComboBoxRenderers.setStudentRenderer(studentCombo);
|
||||
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.lumijiez.gui.util;
|
||||
|
||||
import org.lumijiez.base.Faculty;
|
||||
import org.lumijiez.base.Group;
|
||||
import org.lumijiez.base.Student;
|
||||
import org.lumijiez.enums.Subjects;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class ComboBoxRenderers {
|
||||
public static void setFacultyRenderer(JComboBox<Faculty> facultyCombo) {
|
||||
facultyCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Faculty)
|
||||
setText(((Faculty) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setGroupRenderer(JComboBox<Group> groupCombo) {
|
||||
groupCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Group)
|
||||
setText(((Group) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setStudentRenderer(JComboBox<Student> studentCombo) {
|
||||
studentCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Student)
|
||||
setText(((Student) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setSubjectRenderer(JComboBox<Subjects> subjectCombo) {
|
||||
subjectCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value instanceof Subjects)
|
||||
setText(((Subjects) value).getName());
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.lumijiez.gui.util;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class ComponentDecorator {
|
||||
public static void submitButton(JButton button) {
|
||||
button.setBackground(new java.awt.Color(204, 255, 204));
|
||||
}
|
||||
|
||||
public static void cancelButton(JButton button) {
|
||||
button.setBackground(new java.awt.Color(255, 204, 204));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user