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

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 各位大哥帮帮我! (== and equals)
sss6586576





发贴: 10
积分: 0
于 2004-10-21 15:52 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 java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class bbb extends JApplet implements WindowListener,ActionListener,ItemListener
{
JOptionPane p1=new JOptionPane();
JLabel l1=new JLabel("name");
JLabel l2=new JLabel("nosmoking seat distinct");
JLabel l3=new JLabel("smoking seat distinct");
JCheckBox c1=new JCheckBox();
JCheckBox c2=new JCheckBox();
JTextField t=new JTextField(10);
JButton b=new JButton("确定");


public bbb()
{
Container container = getContentPane();
container.setLayout(new FlowLayout());

container.add(l1);
container.add(t );
container.add(l2);
container.add(c1);
c1.addItemListener(this);
container.add(l3);
container.add(c2);
c2.addItemListener(this);
container.add(b);
b.addActionListener(this);
}
public void windowClosing(WindowEvent e){System.exit(0);}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}

public void itemStateChanged(ItemEvent e)
{

if(e.getSource()==c1&&e.getSource()==c2)
{

p1.showMessageDialog(null,"error");

}

}

public void actionPerformed(ActionEvent e)
{

if(e.getSource()==b)
{
if(t.getText()=="")
{

p1.showMessageDialog(null,"name is null.");

}
}
}
}

它的功能是录入信息.当name 为空时,出现提示框"error",当两个checkbox同时被选时,也出现提示框"error".但界面做出来了,可是事件怎么也弄不出来.
请各位大哥指点,另外,小弟学事件方面的处理.但这是图书馆这方面的书太少了.不知哪位热心大哥可以推荐小弟一本书看.


why edited on 2004-10-21 18:49


JSR 371——Java EE 8新的MVC框架

话题树型展开
人气 标题 作者 字数 发贴时间
4610 各位大哥帮帮我! (== and equals) sss6586576 1953 2004-10-21 15:52
3398 Re:各位大哥帮帮我! qingbo777 89 2004-10-21 16:32

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