|
@@ -0,0 +1,71 @@
|
|
|
|
+/*
|
|
|
|
+ * To change this license header, choose License Headers in Project Properties.
|
|
|
|
+ * To change this template file, choose Tools | Templates
|
|
|
|
+ * and open the template in the editor.
|
|
|
|
+ */
|
|
|
|
+package javaapp1;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import java.awt.Dimension;
|
|
|
|
+
|
|
|
|
+import javax.swing.JFrame;
|
|
|
|
+import javax.swing.JScrollPane;
|
|
|
|
+import javax.swing.JTable;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+public class Tablet extends JFrame {
|
|
|
|
+
|
|
|
|
+ public void createGUI(ArrayList<Student> students) {
|
|
|
|
+ JFrame frame = new JFrame("Test frame");
|
|
|
|
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
+
|
|
|
|
+ String[] columnNames = {
|
|
|
|
+ "ФИО",
|
|
|
|
+ "Английский",
|
|
|
|
+ "Базы данных",
|
|
|
|
+ "Моделирование систем",
|
|
|
|
+ "Право",
|
|
|
|
+ "Термех",
|
|
|
|
+ "Средний балл"
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Object[][] data = listToObject(students);
|
|
|
|
+ JTable table = new JTable(data, columnNames);
|
|
|
|
+
|
|
|
|
+ JScrollPane scrollPane = new JScrollPane(table);
|
|
|
|
+
|
|
|
|
+ frame.getContentPane().add(scrollPane);
|
|
|
|
+ frame.setPreferredSize(new Dimension(450, 200));
|
|
|
|
+ frame.pack();
|
|
|
|
+ frame.setLocationRelativeTo(null);
|
|
|
|
+ frame.setVisible(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void runGUI(ArrayList<Student> students) {
|
|
|
|
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
|
|
|
+ public void run() {
|
|
|
|
+ JFrame.setDefaultLookAndFeelDecorated(true);
|
|
|
|
+ createGUI(students);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Object[][] listToObject(ArrayList<Student> students) {
|
|
|
|
+ Object[][] res = new Object[students.size()][7];
|
|
|
|
+
|
|
|
|
+ Student student;
|
|
|
|
+ for (int i = 0; i < students.size(); i++){
|
|
|
|
+ Object[] ob = new Object[7];
|
|
|
|
+ student = students.get(i);
|
|
|
|
+ ob[0] = student.Name;
|
|
|
|
+ ob[1] = student.markEnglish;
|
|
|
|
+ ob[2] = student.markBD;
|
|
|
|
+ ob[3] = student.markModelingSystems;
|
|
|
|
+ ob[4] = student.markPravo;
|
|
|
|
+ ob[5] = student.markTermeh;
|
|
|
|
+ ob[6] = student.markAverage;
|
|
|
|
+ res[i] = ob;
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+}
|