How to realize a simple Student status Management system by java
This article mainly introduces java how to achieve a simple student status management system, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The details are as follows
Code import java.awt.*;import java.awt.event.*;import java.io.*;import javax.swing.*; public class TestStudentManager {private int rows = 0; private String [] [] unit = new String [rows] [5]; private String [] name = {"name", "language", "Mathematics", "Foreign language", "Total score"}; public JTable table Public static void main (String [] args) {new TestStudentManager ();} TestStudentManager () {JFrame frame = new JFrame ("simulated student management system"); table = new JTable (unit, name); JPanel southPanel = new JPanel (); southPanel.add (new JLabel ("add students"); JButton calc = new JButton ("calculate grades") JButton save = new JButton ("Save student information"); JTextField input = new JTextField (5); southPanel.add (input); southPanel.add (calc); southPanel.add (save); frame.add (new JLabel ("Welcome to the Student Management system", BorderLayout.NORTH); frame.add (southPanel, BorderLayout.SOUTH); frame.add (new JScrollPane (table), BorderLayout.CENTER) Frame.setSize (400,400); frame.setVisible (true); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); input.addActionListener (new ActionListener () {public void actionPerformed (ActionEvent e) {rows = Integer.valueOf (input.getText ()); unit = new String [rows] [5]; table = new JTable (unit, name) System.out.println ("xx"); frame.getContentPane (). RemoveAll (); frame.add (new JScrollPane (table), BorderLayout.CENTER); frame.add (southPanel, BorderLayout.SOUTH); frame.add (new JLabel ("Welcome to the Student Management system", BorderLayout.NORTH); frame.validate () Table.setRowHeight (25);}}); calc.addActionListener (new ActionListener () {public void actionPerformed (ActionEvent e) {for (int I = 0; I < rows; iTunes +) {double sum = 0; boolean flag = true; for (int j = 1; j)