请大家帮忙调试一段程序,100分送上~~~~解决如何在界面上正确的输出 public void actionPerformed(ActionEvent e){}此函数的最后一句加上repaint();就行了~~~~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //程序将10个学生的信息从界面输入,包括学生的学号,姓名,成绩,班级,以及成绩查询密码.//但界面上不会显示学生的成绩以及查询密码//输入完毕后,将学生按学号进行排序,程序具有查询功能,当对学生进行成绩查询功能时,密码通过才会输出成绩.import java.applet.Applet;import java.awt.*;import java.awt.event.*;public class Student1 extends Applet implements ActionListener{ int Datainputed1,Datainputed2; Label prompt=new Label("请输入学生的信息(最多10个): "); TextField input=new TextField(5); Button sorbtn=new Button("排序"); String [][]student=new String [10][5]; String msg=""; public void init() { add(prompt); add(input); add(sorbtn); input.addActionListener(this); sorbtn.addActionListener(this); } public void paint(Graphics g) { for(int i=0;i<10;i++) for(int j=0;j<3;j++) { g.drawString(student[i][j],10+50*j,10+50*i); } g.drawString(msg,10,400); } public void actionPerformed(ActionEvent e) { if(e.getSource()==input) { student[Datainputed1][Datainputed2++]=input.getText(); if(Datainputed1==9&&Datainputed2>4) { prompt.setText("已输入10个学生的信息,不能再输入"); input.setVisible(false); } else { prompt.setText("已输入"+Datainputed1+"个数据,请继续第"+(Datainputed1+1)+"个数据的输入"); input.setText(" "); } if(Datainputed2==5) { Datainputed1++; Datainputed2=0; input.setText(""); } } if(e.getActionCommand()=="排序") { SortProcedure(); sorbtn.setLabel("查找"); prompt.setText("请输入欲查找学生的学号"); input.setVisible(true); input.setText(""); repaint(); } if(e.getActionCommand()=="查找") { String s1=input.getText(); input.setText(""); prompt.setText("请输入该学生的成绩查询密码"); String s2=input.getText(); if(MiMa(s1,s2)) { int f=ChaZhao(s1); msg="您所查询的学生成绩为"+student[f][3]; } else msg="对不起,你没有该学生的成绩查询权限"; repaint(); } repaint(); } void SortProcedure() { String temp; for(int i=0;i<10;i++) for(int j=0;j<9-i;j++) { if(Integer.parseInt(student[j][0])>Integer.parseInt(student[j+1][0])) { temp=student[j][0]; student[j][0]=student[j+1][0]; student[j+1][0]=temp; } } } int ChaZhao(String s) { int k = -1; for(int i=0;i<10;i++) { if(student[i][0]==s) k = i; } return k; } boolean MiMa(String xuehao,String mima) { int i = -1; String temp; boolean j; for(int k=0;k<10;k++) { if(student[k][0]==xuehao) i=k; } temp=student[i][4]; j=temp.equals(mima); return j; }} 申明??? 急!! 生成可执行jar问题! float和Float的区别,floatValue()的作用? 各位大師:菜人有Java小程序,幫忙分析一下。 数据库驱动加载问题 正则表达式在线等 制表符\t在JOptionPane中为什么不起作用? 上海有招java学徒工的么? 在japplet中jcombobox下啦列表不出现,并且jcombobox经常不可见 很有意思的问题,如何动态得到变量名 高分求解 关于中文编码转换问题
//但界面上不会显示学生的成绩以及查询密码
//输入完毕后,将学生按学号进行排序,程序具有查询功能,当对学生进行成绩查询功能时,密码通过才会输出成绩.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Student1 extends Applet implements ActionListener
{
int Datainputed1,Datainputed2;
Label prompt=new Label("请输入学生的信息(最多10个): ");
TextField input=new TextField(5);
Button sorbtn=new Button("排序");
String [][]student=new String [10][5];
String msg="";
public void init()
{
add(prompt);
add(input);
add(sorbtn);
input.addActionListener(this);
sorbtn.addActionListener(this);
}
public void paint(Graphics g)
{
for(int i=0;i<10;i++)
for(int j=0;j<3;j++)
{
g.drawString(student[i][j],10+50*j,10+50*i);
}
g.drawString(msg,10,400);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==input)
{
student[Datainputed1][Datainputed2++]=input.getText();
if(Datainputed1==9&&Datainputed2>4)
{
prompt.setText("已输入10个学生的信息,不能再输入");
input.setVisible(false);
}
else
{
prompt.setText("已输入"+Datainputed1+"个数据,请继续第"+(Datainputed1+1)+"个数据的输入");
input.setText(" ");
}
if(Datainputed2==5)
{
Datainputed1++;
Datainputed2=0;
input.setText("");
}
}
if(e.getActionCommand()=="排序")
{
SortProcedure();
sorbtn.setLabel("查找");
prompt.setText("请输入欲查找学生的学号");
input.setVisible(true);
input.setText("");
repaint();
}
if(e.getActionCommand()=="查找")
{
String s1=input.getText();
input.setText("");
prompt.setText("请输入该学生的成绩查询密码");
String s2=input.getText();
if(MiMa(s1,s2))
{
int f=ChaZhao(s1);
msg="您所查询的学生成绩为"+student[f][3];
}
else
msg="对不起,你没有该学生的成绩查询权限";
repaint();
}
repaint();
}
void SortProcedure()
{
String temp;
for(int i=0;i<10;i++)
for(int j=0;j<9-i;j++)
{
if(Integer.parseInt(student[j][0])>Integer.parseInt(student[j+1][0]))
{
temp=student[j][0];
student[j][0]=student[j+1][0];
student[j+1][0]=temp;
}
}
}
int ChaZhao(String s)
{
int k = -1;
for(int i=0;i<10;i++)
{
if(student[i][0]==s)
k = i;
}
return k;
}
boolean MiMa(String xuehao,String mima)
{
int i = -1;
String temp;
boolean j;
for(int k=0;k<10;k++)
{
if(student[k][0]==xuehao)
i=k;
}
temp=student[i][4];
j=temp.equals(mima);
return j;
}
}