各位,请大家看看下面这段代码,请大家看看错在那里!!!
下面这段代码是一个工资管理系统的主程序,我把出了问题的地方标了出来,起名为login.java
public class Login extends Form
{
int NUM=100;
int index;
Wages[] person;//wages为自定义的一个类的
public Login()
{
super();
initForm();
index=0;
person=new Wages[NUM];
person[index++]=new Wages("01","1","30","男","后勤科","1200","1");
person[index++]=new Wages("02","钱森","32","男","会计科","1500","432589");
person[index++]=new Wages("03","孙丽","28","女","工会","1200","503748");
person[index++]=new Wages("04","李黎","25","男","计算机中心","2000","348767");
person[index++]=new Wages("05","周月","38","女","人事科","1600","453865");
person[index++]=new Wages("06","伍刚","45","男","人事科","1800","523545");
person[index++]=new Wages("07","郑兵","37","男","计算机中心","2500","435332");
person[index++]=new Wages("08","王兰","33","女","后勤科","1300","524225");
person[index++]=new Wages("09","强俊","22","女","计算机中心","1800","3011616");
person[index++]=new Wages("10","吴飞","30","男","厂长室","2000","435353");
}
/**
* Login overrides dispose so it can clean up the
* component list.
*/
public void dispose()
{
super.dispose();
components.dispose();
}
private void button2_click(Object source, Event e)
{
Application.exit();
}
private void button1_click(Object source, Event e)
{
String userIn=edit1.getText();
String passwdIn=edit2.getText();
for(int i=0;i<index;i++)
{ if(person[i].getName ().equals(userIn)&&person[i].getLogin().equals(passwdIn))
{ label4.setText ("登录成功");
Main myForm=new Main();
myForm.showDialog ();
if (myForm.getDialogResult ()==DialogResult.OK ){
this.dispose();}
break;}
else
{ label4.setText("用户名或口令不正确");
edit1.setText ("");
edit2.setText ("");}
}
}
下面的这段是上面的查询所要调的内容,起名为check.java
public class Check extends Form
{
public Login c_myParent;//login是我上面自定义的一个类
public Check()
{
super();
// Required for Visual J++ Form Designer support
initForm();
// TODO: Add any constructor code after initForm call
}
/**
* Check overrides dispose so it can clean up the
* component list.
*/
public void dispose()
{
super.dispose();
components.dispose();
}
private void button1_click(Object source, Event e)
{
String info="";
String userIn=edit1.getText();
String passwdIn=edit2.getText();
try{
for( int i=0;i<c_myParent.index;i++)//在这儿index是Login类的一个
//实例的一个成员变量,在这个类中也可以调用吗,请大家给个答案,就是在一个类中可以调用另一个类的成员变量吗,只听说可以调用方法的,不然这样就乱套了!
{
if(c_myParent.person[i].getName ().equals(userIn)&&c_myParent.person[i].getLogin().equals(passwdIn))
{
label3.setText("");
info+=c_myParent.person[i].toString ()+"\n";
labFlag.setText("编号\t姓名\t年龄\t性别\t部门\t工资");
edit3.setText (info);
wait(60000);//为什么我的程序在这儿出了问题,我作了
//测试,程序并没有执行这个for循环,所以我用了个wait(60000),但程序并没有在
//这儿暂停啊,而且我的界面是调用到这个类的窗口时侯,等我正要看结果窗体却已经
//被销毁了,速度非常快,想问各位我该如何设定更改程序才能成功
}
else
{label3.setText("您不是合法用户,请重新输入!");
edit1.setText("");
edit2.setText("");}
}
}
catch (Exception c)
{
String err=c.toString ();
System.out.println(err);
}
}
private void button2_click(Object source, Event e)
{
label3.setText("");
edit1.setText("");
edit2.setText("");
}
private void button3_click(Object source, Event e)
{
this.dispose ();
}
大家刚才看到我的程序中有人员的一个数组,其中我加了十个人,现在我想把这些人员的信息放到文件中,该如何操作,请大家给个提示,谢谢,高分相送!!!