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

📄 qqclient.java

📁 可实现整个校园网内聊天
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     }
    }
   }
   class zuozhe extends Frame //关于作者的界面
   {Label label1,label2,label3,label4,label5;
   TextField text1,text2,text3,text4,text5;
   Box basebox,boxh1,boxh2;
   zuozhe()
   {super("我的资料");
   setSize(200,200);
   setBounds(300,300,300,240);
   setVisible(true);
   setBackground(color);
   label1=new Label("姓名");
   label2=new Label("学院");
   label3=new Label("班级");
   label4=new Label("QQ号");
   label5=new Label("邮箱");
   text1=new TextField(20);
   text2=new TextField(20);
   text3=new TextField(20);
   text4=new TextField(20);
   text5=new TextField(20);
   text1.setText("杨德青");
   text2.setText("通信与信息工程学院");
   text3.setText("Y0705");
   text4.setText("229922239");
   text5.setText("yangdeqing86@163.com");
   text1.setEditable(false);
   text2.setEditable(false);
   text3.setEditable(false);
   text4.setEditable(false);
   text5.setEditable(false);
   basebox=Box.createHorizontalBox();
   boxh1=Box.createVerticalBox();
   boxh2=Box.createVerticalBox();
   boxh1.add(label1);
   boxh1.add(Box.createVerticalStrut(4));
   boxh1.add(label2);
   boxh1.add(Box.createVerticalStrut(4));
   boxh1.add(label3);
   boxh1.add(Box.createVerticalStrut(4));
   boxh1.add(label4);
   boxh1.add(Box.createVerticalStrut(4));
   boxh1.add(label5);
   boxh2.add(text1);
   boxh2.add(Box.createVerticalStrut(4));
   boxh2.add(text2);
   boxh2.add(Box.createVerticalStrut(4));
   boxh2.add(text3);
   boxh2.add(Box.createVerticalStrut(4));
   boxh2.add(text4);
   boxh2.add(Box.createVerticalStrut(4));
   boxh2.add(text5);
   basebox.add(boxh1);
   basebox.add(boxh2);
   add(basebox);
   validate();
   addWindowListener (new WindowAdapter()
       {public void windowClosing(WindowEvent e)
          {dispose();}
       }
    );
   }
   
   }
   class wenjian extends Frame implements ActionListener//接收文件界面
   {Button button;
    wenjian()
   {super("收到文件,点击接收!");
    setLayout(new BorderLayout());
    setSize(100,100);
    setBounds(300,300,300,240);
    setVisible(true);
    setBackground(color);
    button=new Button("接收文件");
    button.addActionListener(this);
    button.setBackground(color);
    add(button,BorderLayout.CENTER);
    validate();
    addWindowListener (new WindowAdapter()
       {public void windowClosing(WindowEvent e)
          {dispose();}
       }
    );
   }
   public void actionPerformed(ActionEvent e)
   {if(e.getSource()==button)
    {dispose();
     filedialog_save.setVisible(true);
     try
      {File file=new File(filedialog_save.getDirectory(),filename);
       tofile=new FileWriter(file);
       bout=new BufferedWriter(tofile);
       bout.write(filedata,0,filedata.length());
       bout.flush(); 
       bout.close();
       tofile.close();
       }
     catch(IOException e9) {}
     try
        {
        String nn="jieshouwanlixianwenjian"+','+zhujiao;
        byte buffer[]=nn.getBytes();
        data_send=new DatagramPacket(buffer,buffer.length,serveraddress,9999);
        send=new DatagramSocket();
        send.send(data_send);
        dispose();
       }
       catch(Exception e3) {} 
    }
   }
 }
 class yuanfenceshi extends Frame implements ActionListener//附加小功能:缘分测试
 {
   Label label1,label2,label3;
   TextField text1,text2;
   TextArea text;
   Button button;
  Box basebox,boxh1;
  yuanfenceshi()
  {super("缘分测试界面");
   setSize(300,300);
   setBounds(300,300,500,200);
   setVisible(true);
   setBackground(color);
   label1=new Label("男孩姓名");
   label2=new Label("女孩姓名");
   label3=new Label("测试结果");
   text1=new TextField(20);
   text2=new TextField(20);
   text=new TextArea(10,15);
   button=new Button("测试");
   button.setBackground(color);
   button.addActionListener(this);
   basebox=Box.createVerticalBox();
   boxh1=Box.createHorizontalBox();
   boxh1.add(label1);
   boxh1.add(Box.createHorizontalStrut(2));
   boxh1.add(text1);
   boxh1.add(Box.createHorizontalStrut(2));
   boxh1.add(label2);
   boxh1.add(Box.createHorizontalStrut(2));
   boxh1.add(text2);
   basebox.add(boxh1);
   basebox.add(Box.createVerticalStrut(4));
   basebox.add(button);
   basebox.add(Box.createVerticalStrut(4));
   basebox.add(label3);
   basebox.add(Box.createVerticalStrut(4));
   basebox.add(text); 
   add(basebox);
   validate();
   addWindowListener (new WindowAdapter()
       {public void windowClosing(WindowEvent e)
          {dispose();}
       }
    );
   }
   public void actionPerformed(ActionEvent e)
   {if(e.getSource()==button)
    {       text.setText("");
            int qq=0;
	     	String s1=text1.getText();
	        String s2=text2.getText();
			byte a[]=s1.getBytes();
			byte b[]=s2.getBytes();
            int t1,t2,t3;
            t1=s1.length();
            t2=s2.length();
            if(t1<t2) t3=t2;
             else t3=t1;
            for (int i=0;i<t3;i++)
              qq=qq-a[i]&b[i];
			  while(qq>100)
			  { qq=qq/2;
			  }
            text.append("得分:"+String.valueOf(qq)+'\n');
			switch(qq/10)
			{ case 0: text.append("你们是同性恋吗?");break;
			  case 1: text.append("你们根本就是两个世界的人,你们不可能在一起的!");break;
			  case 2: text.append("你们的缘分很浅哦!");break;
			  case 3: text.append("你们的缘分不是很高,但不是没有没有机会!");break;
			  case 4: text.append("虽然你们的缘分不高,但还有机会,继续加油啊!");break;
			  case 5: text.append("你们的缘分还可以,抓住机会哦!");break;
			  case 6: text.append("你们的缘分还可以,记住珍惜哦!");break;
			  case 7: text.append("你们的缘分不错,适合做情侣!");break;
			  case 8: text.append("你们的缘分很高,很有夫妻像的哦");break;
			  case 9: text.append("你们是天作之和!");break;
			  case 10:text.append("你们的缘分指数是最高的,概率是十万分之一!");break;
			  }
    }
   }
 }
 class wannianli extends Frame implements ActionListener,ItemListener,TextListener//附加小功能:日历
 {
  
   SimpleDateFormat ydq=new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒E");
   //日历初始化部分
   Choice choice;
   TextField text1;
   Button button1,button2;
   TextArea text2;
   Box basebox,boxh1,boxh2;
   wannianli()
   { super("万年历");
   setSize(300,300);
   setBounds(300,300,200,200);
   setVisible(true);
   setBackground(color);
       choice=new Choice();
       choice.add("一月");choice.add("二月");choice.add("三月");
       choice.add("四月");choice.add("五月");choice.add("六月");
       choice.add("七月");choice.add("八月");choice.add("九月");
       choice.add("十月");choice.add("十一月");choice.add("十二月");
       choice.addItemListener(this);
       text1=new TextField(4);
       text1.addTextListener(this);
       text2=new TextArea(10,20);
       button1=new Button("上调年份");
       button2=new Button("下调年份");
       button1.addActionListener(this);
       button2.addActionListener(this);
       button1.setBackground(color);
       button2.setBackground(color);
       text2.setBackground(color);
       text1.setBackground(color);
       choice.setBackground(color);
       basebox=Box.createVerticalBox();
   boxh1=Box.createHorizontalBox();
   boxh2=Box.createHorizontalBox();
   boxh1.add(choice);
   boxh1.add(Box.createHorizontalStrut(2));
   boxh1.add(text1);
   boxh2.add(button1);
   boxh2.add(Box.createHorizontalStrut(2));
   boxh2.add(button2);
   basebox.add(boxh1);
   basebox.add(boxh2);
   basebox.add(Box.createVerticalStrut(4));
   basebox.add(text2);
   add(basebox);
   validate();
   addWindowListener (new WindowAdapter()
       {public void windowClosing(WindowEvent e)
          {dispose();}
       }
    );
       Date date3=new Date();
       text1.setText(ydq.format(date3).substring(0,4));
       switch(Integer.parseInt(ydq.format(date3).substring(6,7)))
       { case 1:  choice.select(0);break;
         case 2:  choice.select(1);break;
         case 3:  choice.select(2);break;
         case 4:  choice.select(3);break;
         case 5:  choice.select(4);break;
         case 6:  choice.select(5);break;
         case 7:  choice.select(6);break;
         case 8:  choice.select(7);break;
         case 9:  choice.select(8);break;
         case 0:  choice.select(9);break;
       }
       if(ydq.format(date3).substring(5,7).equals("11")) choice.select(10);
      else if(ydq.format(date3).substring(5,7).equals("12")) choice.select(11); 
     }
     public void actionPerformed(ActionEvent e)
     {if(e.getSource()==button1)
      {text1.setText(String.valueOf(Integer.parseInt(text1.getText())+1));
      }
      else if(e.getSource()==button2)
      {text1.setText(String.valueOf(Integer.parseInt(text1.getText())-1));
      }
     }
     public void textValueChanged(TextEvent e)
     {if(e.getSource()==text1)
      {chaxun();
      }
     }
     public void itemStateChanged(ItemEvent e)
     {chaxun();
     }
     public void chaxun()
     {
      text2.setText("");
      text2.append(" 日 一 二 三 四 五 六\n");
      Calendar 日历=Calendar.getInstance();
      int a=Integer.parseInt(text1.getText());
      int b=choice.getSelectedIndex();
      日历.set(a,b,1);
      int 星期几=日历.get(Calendar.DAY_OF_WEEK)-1;
      String aa[]=new String[星期几+31];
      for(int i=0;i<星期几;i++)
      {aa[i]="  ";
      }
      for(int i=星期几,n=1;i<星期几+31;i++)
      { if(n<=9)
        aa[i]=" "+String.valueOf(n);
        else
        aa[i]=String.valueOf(n);
        n++;
      }
      if((b==3)||(b==5)||(b==8)||(b==10))
      {for(int i=0;i<aa.length;i++)
       if(aa[i].equals("31"))
       aa[i]="\n";
      }
      if((b==1)&&(a%4==0))
      {for(int i=0;i<aa.length;i++)
       if(aa[i].equals("30")||aa[i].equals("31"))
       aa[i]="\n";
      }
      if((b==1)&&(a%4!=0))
      {for(int i=0;i<aa.length;i++)
       if(aa[i].equals("29")||aa[i].equals("30")||aa[i].equals("31"))
       aa[i]="\n";
      }
      Date date4=new Date();
      String dd=ydq.format(date4).substring(8,10);
      if(Integer.parseInt(dd)<10)
      dd=ydq.format(date4).substring(9,10);
      for(int i=0;i<aa.length;i++)
      {
       if(i%7==0)
       {text2.append("\n");
       }
        text2.append(" "+aa[i]);
      }
      String ss=text2.getText();
      int gg=ss.indexOf(dd);
      text2.setSelectionStart(gg);
      text2.setSelectionEnd(gg+2);
      text2.setEditable(false);
     }        
 }
 }
 } 
 public class 	qqclient
 { public static void  main(String kk[])
   {kehuduan hh=new kehuduan();
   }
 }        

⌨️ 快捷键说明

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