新手练练----也做即时通信系统(2)

   继续完善功能,后面的路还很长。。。
   今天还用这个小示例程序给别人讲了次课,发现自己的演讲天赋还是不错的,讲完后闻及感受,说我讲的听通俗易懂的,例子比喻也很不错,开心,呵呵。。。
clientMain.java


          out.println(
this .clientCmd);
            
this .serverMsg  =  in.readLine();
            strTmp 
=   this .serverMsg.split(spliter);
            
if (strTmp[ 0 ].equals( new  String( " getbuddys " )))
            
{
                
this.creatBuddyList(strTmp); //用服务器传过来的好友数据建列表
            }


    
private   void  creatBuddyList(String[] buddys)
    
{
        DefaultMutableTreeNode buddy 
= null;
        
for(int i=1;i<buddys.length;i++)
        
{
            buddy 
= new DefaultMutableTreeNode(buddys[i]);
            root.add(buddy);
        }

    }

    JPanel jPanel1 
=   new  JPanel();
    DefaultMutableTreeNode root 
=   new  DefaultMutableTreeNode( " 我的好友 " );

    JTree buddyTree 
=   new  JTree(root);
    JScrollPane jScrollPane1 
=   new  JScrollPane(buddyTree);

SeverThread.java
  else   if (msgTmp[ 0 ].equals( new  String( " getbuddys " )))
                
{//获取好友列表
                    String clientID = msgTmp[1];//获取客户id号
                    String buddyName;
                    com.vitamin.DataAccess.DBbase myDb 
= new DBbase();
                    
this.sql = "select * from buddies where user = "+clientID;
                    
this.rs =  myDb.executeQuery(this.sql);
                    
while(rs.next())
                    
{
                       buddyName 
= rs.getString("buddy");
                       
this.serverMsg += buddyName;
                    }

                   
this.out.println(this.serverMsg);
                }

运行结果:

6-22-2.GIF
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值