这个网站非常好,分成三大类,分别是Example、Products、Articles,每个大类下又分别设许多小类,还有搜索功能,这样查找起来非常方便。。比如,如果要学习SWT/JFace,只要把Example下的SWTJFaceEclipse研究一下也就可以了。另外,这个网站还有JavaScriptDHTML、C#/CSharp、C/ANSI-C、SQL/MySQL等类。总之,非常好。
2.codeZoo
这是O'Reily旗下的,除了Java之外,还有Ruby、Python。
3.Java学习源代码检索系统
难得看见国产的,好歹也要支持一下,分类也算清楚。
4.Koders
是个综合查询的网站,不过它好像是从代码中查找关键词,包含的语言挺多的。
5.ResourcesforJavaserver-sidedevelopers
确切的说,它是一个资源收集的网站,代码查询并不多。不过它分类相当细,如Articles、Books、Examples、Extensions、Frameworks等类,你可以输入Spring或Hibernate作为关键词搜索一下看看。
-----
Java可视化编程
1、下载JDK(1_5_0_09);
2、下载Eclipse(3.2.1);(我比较喜欢用最新版的^-^)
3、下载相应的EMF(2.2.1)、GEF(3.2.1)、VE(1.2.1);
开始安装:
1、安装JDK;
这个比较容易,标准的Windows安装程序,下一步,再下一步即可,安装完成后,也不需要重启。
2、安装Eclipse;
Eclipse是绿色软件,不需要安装,只需要解压缩,然后即可运行。
为了说明方便,我把它解压缩到C盘根目录下,得到C:\eclipse目录,运行C:\eclipse\eclipse.exe即可。
注意:下面的安装,需要先关闭eclipse程序。
3、安装EMF、GEF、VE;
对于Eclipse来说,这些都是它的插件,所以,安装方法都是一样的。
A、在C:\eclipse目录下,建立四个子目录:C:\eclipse\emf、C:\eclipse\gef、C:\eclipse\ve、C:\eclipse\links;
B、把下载的EMF、GEF、VE都解压缩到相应的目录中,即:把EMF压缩包解压缩到C:\eclipse\emf中,得到C:\eclipse\emf\eclipse目录,以此类推,完成GEF、VE的解压缩;
C、在C:\eclipse\links目录下,新建一个文本文件,名字可随便取,如:link.txt。
然后在link.txt文件中,加入以下三行文字:
path=emf
path=gef
path=VE
注意:这里用的是相对路径,也可以把EMF、GEF、VE解压缩到其它地方,再用绝对路径即可。(应该能看到3个插件,实际运行中只能看到1个,分2次,交换一下path的行的顺序后,3个插件都可以看到了)
4、安装完毕,再次运行Eclipse,它启动时会自动查找links目录下所有的文本文件,并加载其中path指向的所有插件,这里当然包括VE。
A、如果不能确定是否已经加载,可选择菜单Help-SoftwareUpdates-ManageConfiguration,打开ProductConfiguration窗体,在其左边的树形栏里,可以看到已加载的插件。
B、如果加载没有成功,可以试试用Eclipse-clear来运行程序。
用VE写个Hello:
1、新建一个项目;
File-New-Project...,选择“JavaProject”,然后Next,输入一个项目名字:Hello,其它全部默认,最后回车,或者点击“Finish”完成。
2、设置SWT库;
A、选择项目Hello,右键菜单,打开Properties对话框。
B、选择左边树形中的JavaBuildPath,在其设置页中,选择Libraries页,点击“AddLibrary...”;
C、在打开的AddLibrary对话框里,选择StandardWidgetToolkit(SWT),Next;
D、在打开的SWTLibraryOptions对话框中,勾选上“IncludesupportforJFacelibrary”,Finish即可。
E、回到Properties对话框,OK即可。
3、新建Hellworld.java文件;
A、选择项目Hello,右键菜单,New-Other...(或者点击工具栏里新建图标),打开Selecta
wizard对话框,选择Java/VisualClass,Next;
B、在打开的JavaVisualClass对话框中,
在Package里,输入:com.cnblogs.pan;
在Name里,输入:Helloworld;
在Style里,选择SWT/Shell;
勾选上publicstaticvoidmain(String[]args);
最后Finish。
4、到了这一步,应该就可以看到窗体了,那些控件都在Palette里,点开就能看到了。
A、在窗体上右击,选择SetLayout,再选择null;(此处为个人习惯)
B、从Palette里,选中一个Button,并在窗体任意位置画一个Button,在下面的Properties窗口里,设置其text为ClickMe;(Palette视图从windows里打开)
C、选中该按钮,右击选择Events-AddEvent,在打开的对话框中,选择左边的widgetSelected,Finish。
D、这时,光标会自动定位到程序相应的位置,我们在程序里加入下面语句:
publicvoidwidgetSelected(org.eclipse.swt.events.SelectionEvente){
System.out.println("widgetSelected()");
MessageDialog.openInformation(null,"Hello","HelloWorld!");//加入这条语句
}
E、保存程序,点击菜单Run-RunAs-JavaApplication,
一是不是在同一工程目录下,包名和.有没有错二有没有换过JDK如果中途换了JDK那么请把你以前的JDK卸掉在装有时JDK的class-path会有冲突sharenyingye考虑采纳一下。有空到软件测试基地,365testing
共四个java文件,源代码如下:
importjava.awt.*;
importjava.net.*;
importjava.awt.event.*;
importjava.io.*;
importjava.util.Hashtable;
publicclassChatAreaextendsPanelimplementsActionListener,Runnable
{
Socketsocket=null;
DataInputStreamin=null;
DataOutputStreamout=null;
ThreadthreadMessage=null;
TextArea谈话显示区,私聊显示区=null;
TextField送出信息=null;
Button确定,刷新谈话区,刷新私聊区;
Label提示条=null;
Stringname=null;
HashtablelistTable;
ListlistComponent=null;
ChoiceprivateChatList;
intwidth,height;
publicChatArea(Stringname,HashtablelistTable,intwidth,intheight)
setLayout(null);
setBackground(Color.orange);
this.width=width;
this.height=height;
setSize(width,height);
this.listTable=listTable;
this.name=name;
threadMessage=newThread(this);
谈话显示区=newTextArea(10,10);
私聊显示区=newTextArea(10,10);
确定=newButton("送出信息到:");
刷新谈话区=newButton("刷新谈话区");
刷新私聊区=newButton("刷新私聊区");
提示条=newLabel("双击聊天者可私聊",Label.CENTER);
送出信息=newTextField(28);
确定.addActionListener(this);
送出信息.addActionListener(this);
刷新谈话区.addActionListener(this);
刷新私聊区.addActionListener(this);
listComponent=newList();
listComponent.addActionListener(this);
privateChatList=newChoice();
privateChatList.add("大家(*)");
privateChatList.select(0);
add(谈话显示区);
谈话显示区.setBounds(10,10,(width-120)/2,(height-120));
add(私聊显示区);
私聊显示区.setBounds(10+(width-120)/2,10,(width-120)/2,(height-120));
add(listComponent);
listComponent.setBounds(10+(width-120),10,100,(height-160));
add(提示条);
提示条.setBounds(10+(width-120),10+(height-160),110,40);
PanelpSouth=newPanel();
pSouth.add(送出信息);
pSouth.add(确定);
pSouth.add(privateChatList);
pSouth.add(刷新谈话区);
pSouth.add(刷新私聊区);
add(pSouth);
pSouth.setBounds(10,20+(height-120),width-20,60);
publicvoidsetName(Strings)
name=s;
publicvoidsetSocketConnection(Socketsocket,DataInputStreamin,DataOutputStreamout)
this.socket=socket;
this.in=in;
this.out=out;
try
threadMessage.start();
catch(Exceptione)
publicvoidactionPerformed(ActionEvente)
if(e.getSource()==确定||e.getSource()==送出信息)
Stringmessage="";
Stringpeople=privateChatList.getSelectedItem();
people=people.substring(0,people.indexOf("("));
message=送出信息.getText();
if(message.length()0)
try{
if(people.equals("大家"))
out.writeUTF("公共聊天内容:"+name+"说:"+message);
else
out.writeUTF("私人聊天内容:"+name+"悄悄地说:"+message+"#"+people);
catch(IOExceptionevent)
elseif(e.getSource()==listComponent)
privateChatList.insert(listComponent.getSelectedItem(),0);
privateChatList.repaint();
elseif(e.getSource()==刷新谈话区)
谈话显示区.setText(null);
elseif(e.getSource()==刷新私聊区)
私聊显示区.setText(null);
publicvoidrun()
while(true)
Strings=null;
s=in.readUTF();
if(s.startsWith("聊天内容:"))
Stringcontent=s.substring(s.indexOf(":")+1);
谈话显示区.append("\n"+content);
if(s.startsWith("私人聊天内容:"))
私聊显示区.append("\n"+content);
elseif(s.startsWith("聊天者:"))
Stringpeople=s.substring(s.indexOf(":")+1,s.indexOf("性别"));
Stringsex=s.substring(s.indexOf("性别")+2);
listTable.put(people,people+"("+sex+")");
listComponent.add((String)listTable.get(people));
listComponent.repaint();
elseif(s.startsWith("用户离线:"))
StringawayPeopleName=s.substring(s.indexOf(":")+1);
listComponent.remove((String)listTable.get(awayPeopleName));
谈话显示区.append("\n"+(String)listTable.get(awayPeopleName)+"离线");
listTable.remove(awayPeopleName);
Thread.sleep(5);
catch(IOExceptione)
listComponent.removeAll();
listTable.clear();
谈话显示区.setText("和服务器的连接已中断\n必须刷新浏览器才能再次聊天");
break;
catch(InterruptedExceptione)
ChatServer.java
importjava.util.*;
publicclassChatServer
publicstaticvoidmain(Stringargs[])
ServerSocketserver=null;
Socketyou=null;
HashtablepeopleList;
peopleList=newHashtable();
server=newServerSocket(6666);
catch(IOExceptione1)
System.out.println("正在监听");
you=server.accept();
InetAddressaddress=you.getInetAddress();
System.out.println("用户的IP:"+address);
if(you!=null)
Server_threadpeopleThread=newServer_thread(you,peopleList);
peopleThread.start();
else{
continue;
classServer_threadextendsThread
Stringname=null,sex=null;
Filefile=null;
HashtablepeopleList=null;
Server_thread(Sockett,Hashtablelist)
peopleList=list;
socket=t;
in=newDataInputStream(socket.getInputStream());
out=newDataOutputStream(socket.getOutputStream());
{Strings=null;
if(s.startsWith("姓名:"))
name=s.substring(s.indexOf(":")+1,s.indexOf("性别"));
sex=s.substring(s.lastIndexOf(":")+1);
booleanboo=peopleList.containsKey(name);
if(boo==false)
peopleList.put(name,this);
out.writeUTF("可以聊天:");
Enumerationenum=peopleList.elements();
while(enum.hasMoreElements())
Server_threadth=(Server_thread)enum.nextElement();
th.out.writeUTF("聊天者:"+name+"性别"+sex);
if(th!=this)
out.writeUTF("聊天者:"+th.name+"性别"+th.sex);
out.writeUTF("不可以聊天:");
elseif(s.startsWith("公共聊天内容:"))
Stringmessage=s.substring(s.indexOf(":")+1);
((Server_thread)enum.nextElement()).out.writeUTF("聊天内容:"+message);
elseif(s.startsWith("用户离开:"))
{try
if(th!=thisth.isAlive())
th.out.writeUTF("用户离线:"+name);
catch(IOExceptioneee)
peopleList.remove(name);
socket.close();
System.out.println(name+"用户离开了");
elseif(s.startsWith("私人聊天内容:"))
String悄悄话=s.substring(s.indexOf(":")+1,s.indexOf("#"));
StringtoPeople=s.substring(s.indexOf("#")+1);
Server_threadtoThread=(Server_thread)peopleList.get(toPeople);
if(toThread!=null)
toThread.out.writeUTF("私人聊天内容:"+悄悄话);
out.writeUTF("私人聊天内容:"+toPeople+"已经离线");
catch(IOExceptionee)
importjava.applet.*;
ClientChat.java
publicclassClientChatextendsAppletimplementsRunnable
InputNameTextField用户提交昵称界面=null;
ChatArea用户聊天界面=null;
Label提示条;
Panelnorth,center;
Threadthread;
publicvoidinit()
intwidth=getSize().width;
intheight=getSize().height;
listTable=newHashtable();
setLayout(newBorderLayout());
用户提交昵称界面=newInputNameTextField(listTable);
inth=用户提交昵称界面.getSize().height;
用户聊天界面=newChatArea("",listTable,width,height-(h+5));
用户聊天界面.setVisible(false);
提示条=newLabel("正在连接到服务器,请稍等...",Label.CENTER);
提示条.setForeground(Color.red);
north=newPanel(newFlowLayout(FlowLayout.LEFT));
center=newPanel();
north.add(用户提交昵称界面);
north.add(提示条);
center.add(用户聊天界面);
add(north,BorderLayout.NORTH);
add(center,BorderLayout.CENTER);
validate();
publicvoidstart()
if(socket!=nullin!=nullout!=null)
in.close();
out.close();
catch(Exceptionee)
socket=newSocket(this.getCodeBase().getHost(),6666);
提示条.setText("连接失败");
if(socket!=null)
InetAddressaddress=socket.getInetAddress();
提示条.setText("连接:"+address+"成功");
用户提交昵称界面.setSocketConnection(socket,in,out);
north.validate();
if(thread==null)
thread=newThread(this);
thread.start();
publicvoidstop()
thread=null;
this.showStatus(e.toString());
while(thread!=null)
if(用户提交昵称界面.get能否聊天()==true)
用户聊天界面.setVisible(true);
用户聊天界面.setName(用户提交昵称界面.getName());
用户聊天界面.setSocketConnection(socket,in,out);
提示条.setText("祝聊天愉快!");
center.validate();
Thread.sleep(100);
InputNameTextField。java
publicclassInputNameTextFieldextendsPanelimplementsActionListener,Runnable
TextFieldnameFile=null;
Checkboxmale=null,female=null;
CheckboxGroupgroup=null;
Button进入聊天室=null,退出聊天室=null;
Threadthread=null;
boolean能否聊天=false;
publicInputNameTextField(HashtablelistTable)
nameFile=newTextField(10);
group=newCheckboxGroup();
male=newCheckbox("男",true,group);
female=newCheckbox("女",false,group);
进入聊天室=newButton("进入");
退出聊天室=newButton("退出");
进入聊天室.addActionListener(this);
退出聊天室.addActionListener(this);
add(newLabel("昵称:"));
add(nameFile);
add(male);
add(female);
add(进入聊天室);
add(退出聊天室);
退出聊天室.setEnabled(false);
publicvoidset能否聊天(booleanb)
能否聊天=b;
publicbooleanget能否聊天()
return能否聊天;
publicStringgetName()
returnname;
nameFile.setText(""+e);
publicSocketgetSocket()
returnsocket;
if(e.getSource()==进入聊天室)
退出聊天室.setEnabled(true);
if(能否聊天==true)
nameFile.setText("您正在聊天:"+name);
this.setName(nameFile.getText());
Stringsex=group.getSelectedCheckbox().getLabel();
if(socket!=nullname!=null)
out.writeUTF("姓名:"+name+"性别:"+sex);
nameFile.setText("没有连通服务器"+ee);
if(e.getSource()==退出聊天室)
out.writeUTF("用户离开:");
Stringmessage=null;
if(in!=null)
message=in.readUTF();
nameFile.setText("和服务器断开"+e);
if(message.startsWith("可以聊天:"))
能否聊天=true;
elseif(message.startsWith("聊天者:"))
Stringpeople=message.substring(message.indexOf(":")+1);
listTable.put(people,people);
elseif(message.startsWith("不可以聊天:"))
能否聊天=false;
nameFile.setText("该昵称已被占用");
随机交友网站发展终极解密(俗称“轮盘聊天”)
一个“随机视频聊天网站”,与众不同的是,你的聊天对象并不是你主动选择的,而是网站随机分配给你,简单的说,叫“速配”。小刘觉得这很新奇,玩得有些欲罢不能,“跑遍了大半个世界,终于碰到一个中国人”。
Chatroulette也被人们叫做“聊天轮盘”是由一个17岁俄国高中生创立的随机视频聊天网站。该网站提供的的服务很简单,它将用户随机配对,并生成一对的网络视频连接。它使得用户可以与不认识的人进行有趣的聊天。如今这个网站平均每天在线用户已经达到150万
网站名称:滚聊网,该网站是国内出现较早的随机交友网站,基本模式和omegle.com和Chatroulette.com差不多,但是因为是国内的,所以说的都是中文,就解决了语言上交流的障碍,同时,在技术上也加入了头像、声音提示等功能。可以说是目前国内最好的随机交友站。