📄 informationsystem.java
字号:
GradeText.setText("A");
else if ( mark_int <= 69 && mark_int >= 67)
GradeText.setText("A-");
else if ( mark_int <= 66 && mark_int >= 63)
GradeText.setText("B+");
else if ( mark_int <= 62 && mark_int >= 60)
GradeText.setText("B");
else if ( mark_int <= 59 && mark_int >= 57)
GradeText.setText("B-");
else if ( mark_int <= 56 && mark_int >= 53)
GradeText.setText("C+");
else if ( mark_int <= 52 && mark_int >= 50)
GradeText.setText("C");
else if ( mark_int <= 49 && mark_int >= 47)
GradeText.setText("C-");
else if ( mark_int <= 46 && mark_int >= 43)
GradeText.setText("D+");
else if ( mark_int <= 42 && mark_int >= 40)
GradeText.setText("D");
else if ( mark_int <= 39 && mark_int >= 35)
GradeText.setText("E");
else if ( mark_int <= 34 && mark_int >= 0)
GradeText.setText("F");
else
GradeText.setText("Out of Range");
}
catch (NumberFormatException nfe)
{
GradeText.setText("Error");
}
}
private void ClearBTN_actionPerformed(ActionEvent e)
{
NameText.setText("");
MarksText.setText("");
GradeText.setText("");
}
private void SaveBTN_actionPerformed(ActionEvent e)
{
int location_int = Integer.parseInt(location);
for (int x = 0; x < (location_int-1); x++)
{
tempData[x][0] = arrayData[x][0];
tempData[x][1] = arrayData[x][1];
tempData[x][2] = arrayData[x][2];
}
arrayData = new String[location_int][3];
for (int x = 0; x < (location_int-1); x++)
{
arrayData[x][0] = tempData[x][0];
arrayData[x][1] = tempData[x][1];
arrayData[x][2] = tempData[x][2];
}
tempData = new String[location_int][3];
if ((NameText.getText()).equals(""))
JOptionPane.showMessageDialog(null, "Name cannot be blank.\nPlease reenter the name to continue.", "Error", JOptionPane.ERROR_MESSAGE);
else if ((GradeText.getText()).equals("Out of Range") || (GradeText.getText()).equals("Error") || (GradeText.getText()).equals(""))
JOptionPane.showMessageDialog(null, "The marks are entered incorrectly or left blank.\nPlease reenter the marks to continue.", "Error", JOptionPane.ERROR_MESSAGE);
else
{
arrayData [(location_int-1)][0] = NameText.getText();
arrayData [(location_int-1)][1] = MarksText.getText();
arrayData [(location_int-1)][2] = GradeText.getText();
IDText_UN.setText(location);
NameText_UN.setText(arrayData[(location_int-1)][0]);
MarksText_UN.setText(arrayData[(location_int-1)][1]);
GradeText_UN.setText(arrayData[(location_int-1)][2]);
location_int++;
location = Integer.toString(location_int);
temp_location = Integer.parseInt(location);
temp_location = temp_location - 2;
IDText.setText(location);
NameText.setText("");
MarksText.setText("");
GradeText.setText("");
}
}
private void PreviousBTN_actionPerformed(ActionEvent e)
{
int IDText_UN_int = Integer.parseInt(IDText_UN.getText());
if (IDText_UN_int == (Integer.parseInt(location)-(Integer.parseInt(location)-1)))
JOptionPane.showMessageDialog(null, "This is the first record!", "Error", JOptionPane.ERROR_MESSAGE);
else
{
temp_location = temp_location - 1;
IDText_UN.setText(Integer.toString(IDText_UN_int-1));
NameText_UN.setText(arrayData[(temp_location)][0]);
MarksText_UN.setText(arrayData[(temp_location)][1]);
GradeText_UN.setText(arrayData[(temp_location)][2]);
}
}
private void NextBTN_actionPerformed(ActionEvent e)
{
int IDText_UN_int = Integer.parseInt(IDText_UN.getText());
try
{
if (IDText_UN_int == (Integer.parseInt(location)-1))
JOptionPane.showMessageDialog(null, "This is the last record!", "Error", JOptionPane.ERROR_MESSAGE);
else
{
temp_location = temp_location + 1;
IDText_UN.setText(Integer.toString(IDText_UN_int+1));
NameText_UN.setText(arrayData[(temp_location)][0]);
MarksText_UN.setText(arrayData[(temp_location)][1]);
GradeText_UN.setText(arrayData[(temp_location)][2]);
}
}
catch (ArrayIndexOutOfBoundsException aioobe)
{
JOptionPane.showMessageDialog(null, "This is the last record!", "Error", JOptionPane.ERROR_MESSAGE);
IDText_UN.setText(Integer.toString(IDText_UN_int));
}
}
private void SearchBTN_actionPerformed(ActionEvent e)
{
Object o = TypeCombo.getSelectedItem();
int x, y, counter;
String comboString = o.toString(), searchString = SearchText.getText();
if (searchString.equals(""))
{
JOptionPane.showMessageDialog(null, "You must input a value!", "Error", JOptionPane.ERROR_MESSAGE);
}
else
{
try
{
if (comboString.equals("Name (Case Sensitive)"))
{
counter = 0;
for (x = 0; x < arrayData.length; x++)
{
if ((arrayData[x][0]).contains(searchString))
counter = counter + 1;
}
if (counter != 0)
{
JOptionPane.showMessageDialog(null, "Results found: " + counter, "Name Result", JOptionPane.INFORMATION_MESSAGE);
ResultLabel.setText("Results found: " + counter);
searchArrayLocation = new int[counter];
y = 0;
for (x = 0; x < arrayData.length; x++)
{
if ((arrayData[x][0]).contains(searchString))
{
searchArrayLocation[y] = x;
y++;
}
}
}
else if (counter == 0)
{
JOptionPane.showMessageDialog(null, "There are no results found.", "Name Result", JOptionPane.INFORMATION_MESSAGE);
ResultLabel.setText("No results found.");
}
}
else if (comboString.equals("Marks"))
{
counter = 0;
for (x = 0; x < arrayData.length; x++)
{
if ((arrayData[x][1]).contains(searchString))
counter = counter + 1;
}
if (counter != 0)
{
JOptionPane.showMessageDialog(null, "Results found: " + counter, "Marks Result", JOptionPane.INFORMATION_MESSAGE);
ResultLabel.setText("Results found: " + counter);
searchArrayLocation = new int[counter];
y = 0;
for (x = 0; x < arrayData.length; x++)
{
if ((arrayData[x][1]).contains(searchString))
{
searchArrayLocation[y] = x;
y++;
}
}
}
else if (counter == 0)
{
JOptionPane.showMessageDialog(null, "There are no results found.", "Marks Result", JOptionPane.INFORMATION_MESSAGE);
ResultLabel.setText("No results found.");
}
}
else if (comboString.equals("Grade (Case Sensitive)"))
{
counter = 0;
for (x = 0; x < arrayData.length; x++)
{
if ((arrayData[x][2]).contains(searchString))
counter = counter + 1;
}
if (counter != 0)
{
JOptionPane.showMessageDialog(null, "Results found: " + counter, "Grade Result", JOptionPane.INFORMATION_MESSAGE);
ResultLabel.setText("Results found: " + counter);
searchArrayLocation = new int[counter];
y = 0;
for (x = 0; x < arrayData.length; x++)
{
if ((arrayData[x][2]).contains(searchString))
{
searchArrayLocation[y] = x;
y++;
}
}
}
else if (counter == 0)
{
JOptionPane.showMessageDialog(null, "There are no results found.", "Grade Result", JOptionPane.INFORMATION_MESSAGE);
ResultLabel.setText("No results found.");
}
}
}
catch (NullPointerException npe)
{
JOptionPane.showMessageDialog(null, "There are no values in the database.", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
public static void main(String[] args)
{
new InformationSystem();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -