⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.java

📁 这是我收集的毕业师兄的毕业设计,具体的功能我也不清楚,不过是可以用来答辩的,完整的毕业设计,有源代码,可爱执行文件,文档资料.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            if((choiceend+20)<=cnamemessage.length())
            {choicestart+=20;choiceend+=20;}
            else 
            {choicestart+=20;choiceend+=(cnamemessage.length()-choicestart);}   
           }
        choicestart=0;choiceend=10;
        for(int i=1;i<=cnumber;i++)
            {cname1.add(cnamemessage.substring(choicestart,choiceend));
                 if((choiceend+20)<=cnamemessage.length())
            {choicestart+=20;choiceend+=20;}
            else 
            {choicestart+=20;choiceend+=(cnamemessage.length()-choicestart);}
             }
          }
         number--;
        if(number>0)
        { String cnamemessage=new String(s.substring(deptnumber+82,deptnumber+160).trim());
        cnumber=(cnamemessage.length())/14;
        choicestart=10;choiceend=14;
        for(int i=1;i<=cnumber;i++)
           {array_port[2][i]=Integer.parseInt((cnamemessage.substring(choicestart,choiceend)));
            if((choiceend+20)<=cnamemessage.length())
            {choicestart+=20;choiceend+=20;}
            else 
            {choicestart+=20;choiceend+=(cnamemessage.length()-choicestart);}   
           }
        choicestart=0;choiceend=10;
        for(int i=1;i<=cnumber;i++)
            {cname2.add(cnamemessage.substring(choicestart,choiceend));
                 if((choiceend+20)<=cnamemessage.length())
            {choicestart+=20;choiceend+=20;}
            else 
            {choicestart+=20;choiceend+=(cnamemessage.length()-choicestart);}
             }
          }
         number--;
        if(number>0)
        { String cnamemessage=new String(s.substring(deptnumber+163,deptnumber+240).trim());
        cnumber=(cnamemessage.length())/14;
        choicestart=10;choiceend=14;
        for(int i=1;i<=cnumber;i++)
           {array_port[3][i]=Integer.parseInt((cnamemessage.substring(choicestart,choiceend)));
            if((choiceend+20)<=cnamemessage.length())
            {choicestart+=20;choiceend+=20;}
            else 
            {choicestart+=20;choiceend+=(cnamemessage.length()-choicestart);}   
           }
        choicestart=0;choiceend=10;
        for(int i=1;i<=cnumber;i++)
            {cname3.add(cnamemessage.substring(choicestart,choiceend));
                 if((choiceend+20)<=cnamemessage.length())
            {choicestart+=20;choiceend+=20;}
            else 
            {choicestart+=20;choiceend+=(deptmessage.length()-choicestart);}
             }
          }
		  for(int i=1;i<=condeptnumber;i++)
		{if(choice.getItem(i).trim().equals("manage"))
			{choice.remove(i);choice.insert("管理部",i);}
		 else if(choice.getItem(i).trim().equals("man"))
			{choice.remove(i);choice.insert("人事部",i);}
		 else if(choice.getItem(i).trim().equals("thing"))
			{choice.remove(i);choice.insert("物流部",i);}}
		  a_receive.setForeground(Color.red);
	 pnorth.add(lname);pnorth.add(passname);
	 pnorth.add(lsent);pnorth.add(choice);
	 pnorth.add(cname1);pnorth.add(cname2);pnorth.add(cname3);
	pcenter.add(w_sent);pcenter.add(smessage);pcenter.add(w_receive);pcenter.add(a_receive);
	 passname.setEnabled(false);
	psouth.add(b1);psouth.add(b2);
	 cname2.setVisible(false);
        cname3.setVisible(false);
          b1.addActionListener(this);
		  b2.addActionListener(this);
	   choice.addItemListener(this);
           cname1.addItemListener(this);
            cname2.addItemListener(this);
           cname3.addItemListener(this);
          me_item1.addActionListener(this);me_item2.addActionListener(this);me_item3.addActionListener(this);me_item4.addActionListener(this);
         me_item5.addActionListener(this);me_item6.addActionListener(this);me_item7.addActionListener(this);me_item8.addActionListener(this);
         me_item9.addActionListener(this);
me_item14.addActionListener(this);me_item15.addActionListener(this);
	 add("North",pnorth);
	 add("Center",pcenter);
	 add("South",psouth);
        // add("East",online);
    Thread thread=new Thread(this);
    thread.start();
    addWindowListener(new WindowAdapter()
		{public void windowClosing(WindowEvent e)
			{try{String man_out=new String(Client.hong.RSA("out"+passname.getText()));Client.output.writeUTF(man_out);System.exit(0);}
                         catch(Exception e1){}
			}
		});
		show();
	}
public void itemStateChanged(ItemEvent e)
	{x=cname1.getBounds().x;y=cname1.getBounds().y;
        String tr=new String("sfsd.dat");
	if(choice.getSelectedIndex()==1)
		{choiceport=1;
                  cname1.setVisible(true);
                 cname2.setVisible(false);
		 cname3.setVisible(false);
		 cname1.setLocation(x,y);
                 cname2.select(0);cname3.select(0);
		 }
         else if(choice.getSelectedIndex()==2)
		{choiceport=2;cname1.setVisible(false);
                cname2.setVisible(true);
		 cname3.setVisible(false);
		cname2.setLocation(x,y);
                cname1.select(0);cname3.select(0);
		 }
	else if(choice.getSelectedIndex()==3)
		{choiceport=3;cname1.setVisible(false);
                 cname2.setVisible(false);
		 cname3.setVisible(true);
		cname3.setLocation(x,y);
                cname1.select(0);cname2.select(0);
		 }
           if(cname1.getSelectedIndex()==1)
		{cnameport=1;toman=cname1.getSelectedItem();}
          else if(cname1.getSelectedIndex()==2)
		{cnameport=2;toman=cname1.getSelectedItem();}
          else if(cname1.getSelectedIndex()==3)
		{cnameport=3;toman=cname1.getSelectedItem();}
          else if(cname1.getSelectedIndex()==4)
		{cnameport=4;toman=cname1.getSelectedItem();}
          else if(cname2.getSelectedIndex()==1)
		{cnameport=1;toman=cname2.getSelectedItem();}
          else if(cname2.getSelectedIndex()==2)
		{cnameport=2;toman=cname2.getSelectedItem();}
          else if(cname2.getSelectedIndex()==3)
		{cnameport=3;toman=cname2.getSelectedItem();}
          else if(cname2.getSelectedIndex()==4)
		{cnameport=4;toman=cname2.getSelectedItem();}
          else if(cname3.getSelectedIndex()==1)
		{cnameport=1;toman=cname3.getSelectedItem();}
          else if(cname3.getSelectedIndex()==2)
		{cnameport=2;toman=cname3.getSelectedItem();}
          else if(cname3.getSelectedIndex()==3)
		{cnameport=3;toman=cname3.getSelectedItem();}
          else if(cname3.getSelectedIndex()==4)
		{cnameport=4;toman=cname3.getSelectedItem();}


	}
public void run()
{ DatagramSocket mail_data=null;
  try{mail_data=new DatagramSocket(inport);  }
catch(Exception e){}
while(true)
 {if(mail_data==null) break;
  else
     try{mail_data.receive(pack);
     int length=pack.getLength();
     InetAddress adress =pack.getAddress();
     int port=pack.getPort();
     String message=new String(pack.getData(),0,length);
	 if(message.startsWith("stop"))
	  {wmessage wm=new wmessage("提示窗口","Sorry,你被强迫下线","wrong.jpg");wm.setVisible(true);this.dispose();}
	  
    a_receive.append(message+"\n");
        }
     catch(Exception e){}
   }
 }
public void actionPerformed(ActionEvent e)
	{if(e.getSource()==me_item1)
                  {update=new updateword();update.setVisible(true);}
         else if(e.getSource()==me_item2)
                  {this.dispose();try{String man_out=new String(Client.hong.RSA("out"+passname.getText()));Client.output.writeUTF(man_out);Client.w_pass.setVisible(true);}
                   catch(Exception e1){}
                  }
         else if(e.getSource()==me_item3)
                  {try{String man_out=new String(Client.hong.RSA("out"+passname.getText()));Client.output.writeUTF(man_out);System.exit(0);}
                   catch(Exception e1){}
                  }
         else if(e.getSource()==me_item4)
                  {try{String man_online=new String(Client.hong.RSA("whoonline"));Client.output.writeUTF(man_online);}
                   catch(Exception e1){}
                  }
         else if(e.getSource()==me_item5)
                  {compare com=new compare();com.setVisible(true);}
         else if(e.getSource()==me_item6)
                  {seesource ss=new seesource(1);}
         else if(e.getSource()==me_item7)
                  {seesource ss=new seesource(2);}
         else if(e.getSource()==me_item8)
                  {seesource ss=new seesource(3);}
         else if(e.getSource()==me_item9)
                  {seesource ss=new seesource(4);}
         else if(e.getSource()==me_item14)
                  {file_open.setVisible(true);try{System.out.println(""+Client.hong.file_symmetry(file_open.getDirectory()+file_open.getFile()));wmessage jia=new wmessage("加密成功","      文件加密完毕","提示.jpg");}
                   catch(Exception e1){}
                   }
         else if(e.getSource()==me_item15)
                  {file_open.setVisible(true);try{System.out.println(""+Client.dehong.de_file_symmetry(file_open.getDirectory()+file_open.getFile()));wmessage jie=new wmessage("解密成功","      文件解密完毕","提示.jpg");}
                   catch(Exception e1){}}
         
	else if(e.getSource()==b1)
		{   if(choiceport==0||cnameport==0)
			{wmessage wmport=new wmessage("错误提示","   请选择发信人","wrong.jpg");}
		    else{Date date2=new Date();
		       String senddata=new String("from  "+passname.getText()+"   to  "+toman+"     "+date2.toString().substring(11,19)+"\n"+smessage.getText()+"\n");
               sen.smess(senddata,array_port[choiceport][cnameport]);
			   sen.smess(senddata,8888);
               try{Client.output.writeUTF(Client.hong.RSA("sendmessage"+toman+"\1"+senddata+"\2"+detoday));}
               catch(Exception e1){}
               a_receive.append(senddata);
               String temp=new String("");String s;BufferedReader in;
               try{FileReader in_file;
               File f=new File(Client.user_name+"/"+today+".txt");
               boolean is_exit=f.exists();
               if(is_exit)
                {in_file=new FileReader(f);
              in=new BufferedReader(in_file);
              try{while((s=in.readLine())!=null)
               temp+=s;
              }
           catch(IOException exp){}
            }
           FileWriter tofile=new FileWriter(f);
           BufferedWriter out=new BufferedWriter(tofile);
           out.write(temp+senddata,0,(temp+senddata).length());
           out.flush();
           tofile.close();out.close();
             }
           catch(FileNotFoundException e1){}
           catch(IOException e1){}
          try{ Client.hong.Messagebrief(Client.user_name+"/"+today);}
           catch(Exception e1){}
			}
		}
		else if(e.getSource()==b2)
		{a_receive.setText("");}
	}
}
/****************************************更改密码窗口****************************************************************/
class updateword extends Frame implements ActionListener
{Label label1=new Label("请输入旧密码");Label label2=new Label("请输入新密码");Label label3=new Label("请再输入新密码");
Button b1=new Button("确定");Button b2=new Button("取消");Panel pcen=new Panel();Panel psou=new Panel();
TextField t1=new TextField(10);TextField t2=new TextField(10);TextField t3=new TextField(10);
  updateword()
   {super("修改密码");
    setBounds(300,200,350,200);
        setVisible(false);
        setResizable(false);
        t1.setEchoChar('*'); t2.setEchoChar('*'); t3.setEchoChar('*');
       pcen.setLayout(new GridLayout(5,4));
pcen.add(new Label());pcen.add(new Label());pcen.add(new Label());pcen.add(new Label());
pcen.add(new Label());pcen.add(label1);pcen.add(t1);pcen.add(new Label());
pcen.add(new Label());pcen.add(label2);pcen.add(t2);pcen.add(new Label());
pcen.add(new Label());pcen.add(label3);pcen.add(t3);pcen.add(new Label());
pcen.add(new Label());pcen.add(new Label());pcen.add(new Label());pcen.add(new Label());
psou.setLayout(new GridLayout(1,6));psou.add(new Label());psou.add(new Label());psou.add(b1);psou.add(b2);psou.add(new Label());psou.add(new Label());
add("Center",pcen);add("South",psou);
b1.addActionListener(this);b2.addActionListener(this);
addWindowListener(new WindowAdapter()
		{public void windowClosing(WindowEvent e)
			{setVisible(false);
			}
		});

}
public void actionPerformed(ActionEvent e)
	{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -