📄 informationsystem.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.Arrays;
public class InformationSystem extends JFrame
{
private JTabbedPane RecordPanel;
private JPanel contentPane;
private JLabel IDLabel;
private JLabel NameLabel;
private JLabel MarksLabel;
private JLabel GradeLabel;
private JTextField IDText;
private JTextField NameText;
private JTextField MarksText;
private JTextField GradeText;
private JButton ClearBTN;
private JButton SaveBTN;
private JLabel IDLabel_UN;
private JLabel NameLabel_UN;
private JLabel MarksLabel_UN;
private JLabel GradeLabel_UN;
private JTextField IDText_UN;
private JTextField NameText_UN;
private JTextField MarksText_UN;
private JTextField GradeText_UN;
private JButton PreviousBTN;
private JButton NextBTN;
private JTextField SearchText;
private JComboBox TypeCombo;
private JButton SearchBTN;
private JLabel ResultLabel;
private JPanel RecordDataPanel;
private JPanel ViewDataPanel;
private JPanel SearchDataPanel;
String location = "1";
String arrayData[][] = new String[1][3];
String tempData[][] = new String[1][3];
int searchArrayLocation[];
int temp_location;
public InformationSystem()
{
super();
initializeComponent();
this.setVisible(true);
}
private void initializeComponent()
{
RecordPanel = new JTabbedPane();
contentPane = (JPanel)this.getContentPane();
IDLabel = new JLabel();
NameLabel = new JLabel();
MarksLabel = new JLabel();
GradeLabel = new JLabel();
IDText = new JTextField();
NameText = new JTextField();
MarksText = new JTextField();
GradeText = new JTextField();
ClearBTN = new JButton();
SaveBTN = new JButton();
IDLabel_UN = new JLabel();
NameLabel_UN = new JLabel();
MarksLabel_UN = new JLabel();
GradeLabel_UN = new JLabel();
IDText_UN = new JTextField();
NameText_UN = new JTextField();
MarksText_UN = new JTextField();
GradeText_UN = new JTextField();
PreviousBTN = new JButton();
NextBTN = new JButton();
SearchText = new JTextField();
TypeCombo = new JComboBox();
SearchBTN = new JButton();
ResultLabel = new JLabel();
RecordDataPanel = new JPanel();
ViewDataPanel = new JPanel();
SearchDataPanel = new JPanel();
RecordPanel.addTab("Record Data", RecordDataPanel);
RecordPanel.addTab("View Data", ViewDataPanel);
RecordPanel.addTab("Search Data", SearchDataPanel);
RecordPanel.setTabPlacement(JTabbedPane.LEFT);
contentPane.setLayout(null);
addComponent(contentPane, RecordPanel, 10,10,315,155);
IDLabel.setText("ID");
IDLabel.setPreferredSize(new Dimension(40, 15));
IDText.setPreferredSize(new Dimension(150, 22));
IDText.setText(location);
NameLabel.setText("Name");
NameLabel.setPreferredSize(new Dimension(40, 15));
NameText.setPreferredSize(new Dimension(150, 22));
MarksLabel.setText("Marks");
MarksLabel.setPreferredSize(new Dimension(40, 15));
MarksText.setPreferredSize(new Dimension(150, 22));
MarksText.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e)
{
MarksText_keyReleased(e);
}
});
GradeLabel.setText("Grade");
GradeLabel.setPreferredSize(new Dimension(40, 15));
GradeText.setPreferredSize(new Dimension(150, 22));
IDText.setEditable(false);
GradeText.setEditable(false);
IDLabel_UN.setText("ID");
IDText_UN.setEditable(false);
IDLabel_UN.setPreferredSize(new Dimension(40, 15));
IDText_UN.setPreferredSize(new Dimension(150, 22));
IDText_UN.setText(location);
NameLabel_UN.setText("Name");
NameText_UN.setEditable(false);
NameLabel_UN.setPreferredSize(new Dimension(40, 15));
NameText_UN.setPreferredSize(new Dimension(150, 22));
MarksLabel_UN.setText("Marks");
MarksText_UN.setEditable(false);
MarksLabel_UN.setPreferredSize(new Dimension(40, 15));
MarksText_UN.setPreferredSize(new Dimension(150, 22));
GradeLabel_UN.setText("Grade");
GradeText_UN.setEditable(false);
GradeLabel_UN.setPreferredSize(new Dimension(40, 15));
GradeText_UN.setPreferredSize(new Dimension(150, 22));
ResultLabel.setHorizontalAlignment(SwingConstants.CENTER);
ResultLabel.setText("No Result");
ResultLabel.setPreferredSize(new Dimension(150, 15));
ClearBTN.setText("Clear");
ClearBTN.setPreferredSize(new Dimension(80, 30));
ClearBTN.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
ClearBTN_actionPerformed(e);
}
});
SaveBTN.setText("Save");
SaveBTN.setPreferredSize(new Dimension(80, 30));
SaveBTN.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
SaveBTN_actionPerformed(e);
}
});
PreviousBTN.setText("Previous");
PreviousBTN.setPreferredSize(new Dimension(90, 30));
PreviousBTN.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
PreviousBTN_actionPerformed(e);
}
});
NextBTN.setText("Next");
NextBTN.setPreferredSize(new Dimension(90, 30));
NextBTN.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
NextBTN_actionPerformed(e);
}
});
TypeCombo.addItem("Name (Case Sensitive)");
TypeCombo.addItem("Marks");
TypeCombo.addItem("Grade (Case Sensitive)");
TypeCombo.setMaximumRowCount(3);
TypeCombo.setPreferredSize(new Dimension(160, 22));
SearchText.setPreferredSize(new Dimension(160, 22));
SearchBTN.setText("Search");
SearchBTN.setPreferredSize(new Dimension(90, 30));
SearchBTN.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
SearchBTN_actionPerformed(e);
}
});
RecordDataPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
RecordDataPanel.add(IDLabel, 0);
RecordDataPanel.add(IDText, 1);
RecordDataPanel.add(NameLabel, 2);
RecordDataPanel.add(NameText, 3);
RecordDataPanel.add(MarksLabel, 4);
RecordDataPanel.add(MarksText, 5);
RecordDataPanel.add(GradeLabel, 6);
RecordDataPanel.add(GradeText, 7);
RecordDataPanel.add(ClearBTN, 8);
RecordDataPanel.add(SaveBTN, 9);
ViewDataPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
ViewDataPanel.add(IDLabel_UN, 0);
ViewDataPanel.add(IDText_UN, 1);
ViewDataPanel.add(NameLabel_UN, 2);
ViewDataPanel.add(NameText_UN, 3);
ViewDataPanel.add(MarksLabel_UN, 4);
ViewDataPanel.add(MarksText_UN, 5);
ViewDataPanel.add(GradeLabel_UN, 6);
ViewDataPanel.add(GradeText_UN, 7);
ViewDataPanel.add(PreviousBTN, 8);
ViewDataPanel.add(NextBTN, 9);
SearchDataPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
SearchDataPanel.add(TypeCombo, 0);
SearchDataPanel.add(SearchText, 1);
SearchDataPanel.add(SearchBTN, 2);
SearchDataPanel.add(ResultLabel, 3);
this.setTitle("Information System");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(340, 200));
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
private void MarksText_keyReleased(KeyEvent e)
{
try
{
int mark_int = Integer.parseInt(MarksText.getText());
if ( mark_int <= 100 && mark_int >= 70)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -