Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区 » Java与OOP初步  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请各位帮忙看看哪里出错了(Cannot invoke length() on the array type char[])
binghuo007





发贴: 13
积分: 0
于 2006-03-15 09:54 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
多谢了

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
*
* @author FC
*/
public class LoginPanel extends JFrame {
JPanel panel=new JPanel();
JLabel label1=new JLabel("用户名");
JLabel label2=new JLabel("密码");
JTextField field1=new JTextField(10);
JPasswordField field2=new JPasswordField(10);
JButton btl1=new JButton("登陆");
JButton btl2=new JButton("取消");
JButton btl3=new JButton("重填");
public LoginPanel() {
this.initb();
}
public void initb(){

this.getContentPane().add(panel);
panel.add(label1);
panel.add(field1);
panel.add(label2);
panel.add(field2);
panel.add(btl1);
panel.add(btl2);
panel.add(btl3);
MyActionListener ma=new MyActionListener();
btl1.addActionListener(ma);
btl3.addActionListener(new MyActionListener());
}
class MyActionListener implements ActionListener{
public void actionPerformed(ActionEvent e){
Object obj=e.getSource();
if(obj==btl1){
if(field1.getText().length()==0){
JOptionPane.showMessageDialog(null ,"用户名不能为空");
}
if(field2.getPassword().length()==0){
JOptionPane.showMessageDialog(null,"密码不能为空");
}

else {
JOptionPane.showMessageDialog(null,"即将转入页面,请稍候");
}
}
else if(obj==btl3){
field1.setText("");
field2.setText("");
}
}
}
public void displayDetails(){
this.show();
this.setSize(400, 400);
this.setDefaultCloseOperation(3);
}
public static void main(String args[]){
LoginPanel p=new LoginPanel();
p.displayDetails();
}

}


why edited on 2006-03-15 17:15

作者 Re:请各位帮忙看看哪里出错了 [Re:binghuo007]
hanlichen





发贴: 4
积分: 0
于 2006-03-15 11:37 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
if (field2.getPassword().length() == 0)


作者 Re:请各位帮忙看看哪里出错了 [Re:binghuo007]
hanlichen





发贴: 4
积分: 0
于 2006-03-15 11:38 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Cannot invoke length() on the array type char[]


作者 Re:请各位帮忙看看哪里出错了 [Re:binghuo007]
JavaandC





发贴: 230
积分: 15
于 2006-03-15 12:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
if(field2.getPassword().length()==0) 改成 if(field2.getPassword().length==0)


作者 Re:请各位帮忙看看哪里出错了 [Re:binghuo007]
piaoling





发贴: 26
积分: 0
于 2006-03-15 16:49 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
呵呵。。



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923