|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
java比较简单,没有C++的烦琐,但学习时最好有C++为基础.与JSP和SQL起应用,功能强大.
都要用到JBuilder里的一个组件,
你能够往JBuilder目次下拷,
或本人用JDK的组件改一下
NO1:这个程序挪用Foxmail发送函件
/*这个程序要用到Jbuilder的几个类*/
importjava.awt.*;
importjava.awt.event.*;
importjava.applet.*;
importborland.jbcl.layout.*;
importborland.jbcl.control.*;
importjava.net.*;
publicclassEmailAppletextendsApplet{
Buttonbutton;
TextFieldtextField;
publicEmailApplet(){}
publicvoidinit(){
try{
jbInit();}
catch(Exceptione){
e.printStackTrace();}
}//endofinit()
publicvoidjbInit()throwsException{
setLayout(newBorderLayout());
button=newButton("sendMail");
textField=newTextField();
add("North",textField);
add("South",button);
}//endofjbInit()
publicbooleanaction(Evente,Objectarg){
if(arg.equals("sendMail")){
try{
/*注重哦,这里是次要代码!!*/
Stringmailto=textField.getText();
URLurl=newURL(mailto);
AppletContextac=this.getAppletContext();
ac.showDocument(url);}
catch(Exceptione2){
System.out.println(e2.toString());}
}//endofif
else{
returnsuper.action(e,arg);}
returntrue;
}//endofaction()
}//endofEmailApplet
NO2:这个程序间接发送函件:
importborland.jbcl.layout.*;
importborland.jdbl.*;
importjava.awt.*;
importjava.applet.Applet;
importjava.util.StringTokenizer;
importjava.net.Socket;
importjava.io.PrintStream;
importjava.lang.Exception;
importjava.awt.event.ActionEvent;
publicclassMailAppletextendsApplet{
booleanisStandalone=false;
PaneLayoutpanelLayout1=newPaneLayout();
panelpanel1=newPanel();
Labellabel1=newLabel();
XYLayoutxYLayout1=newXYLayout();
LabelLabel2=newLabel();
TextFieldtextField1=newTextField();
TextFieldtextField2=newTextField();
Labellable3=newLabel();
TextAreatextArea1=newTextArea();
Buttonbutton1=newButton();
Buttonbutton2=newButton();
privateintSMTP_PORT=25;
Frameframe=newFrame();
Colorbgcolor=null;
Stringsend="";
Stringget="";
publicMailApplet(){}
publicvoidinit(){
try{
intc1=Integer.parseInt(getParameter("color1"));
intc2=Integer.parseInt(getParameter("color2"));
intc3=Integer.parseInt(getParameter("color3"));
bgcolor=newColor(c1,c2,c3);
SMTP_PORT=Integer.parseInt(getParameter("port"));
send=getParameter("send");
get=getParameter("get");
jbInit();}
catch(Exceptione){
e.printStackTrace();}
}//endofinit()
/*Componentinitialization*/
privatevoidjbInit()throwsException{
this.setSize(newDimension(332,280));
panel1.setBackground(bgcolor);
label1.setAlignment(2);
label1.setText("收信人地点:");
label2.setAlignment(2);
label2.setText("寄信人地点:");
label3.setAlignment(2);
label3.setText("内容:");
button1.setLabel("发送");
button1.addActionListener(newMailApplet_button1_actionAdapter(this));
button2.setLabel("清除");
button2.addActionListener(newMailApplet_button2_actionAdapter(this));
panel1.setLayout(xYLayout);
this.setLayout(panelLayout1);
thsi.add(panel1,newPaneConstraints("panel1","panel1",PaneConstraints.ROOT,1.0f));
panel1.add(label1,newXYConstraints(10,5,80,20));
panel1.add(label2,newXYConstraints(10,30,80,20));
panel1.add(textField1,newXYConstraints(95,5,200,20));
panel1.add(textField2,newXYConstraints(95,30,200,20));
panel1.add(label3,newXYConstraints(10,60,80,20));
panel1.add(textArea1,newXYConstraints(10,80,300,150));
panel1.add(button1,newXYConstraints(50,240,80,25));
panel1.add(button2,newXYConstraints(160,240,80,25));
textField1.setText(get);
textField2.setText(send);
}//endofjbInit()
publicStringgetAppletInfo(){
return"AppletInformation";}
publicString[][]getParameteInfo(){
returnnull;}
voidsendMail(){
Stringsender=textField2.getText();
Stringgeter=textField1.getText();
Stringmemo=textArea1.getText();
StringTokenizerst=newStringTokenizer(sender,"@");
intcount=st.countTokens();
if(count!=2){
MessageDialogmdlg=newMessageDialog(frame,"邮件地点毛病","你的发信人地点毛病,请确认后从头发送!!",1);
mdlg.show();
textField2.selectAll();
return;}
StringsenderName=st.nextToken();
StringsenderHost=st.nextToken();
st=newStringTokenizer(geter,"@");
count=st.countTokens();
if(count!=2){
MessageDialogmdlg=newMessageDialog(frame,"邮件地点毛病","你的收信人地点毛病,请确认后从头发送!!",1);
mdlg.show();
textField1.selectAll();
return;}
StringgeterName=st.nextToken();
StringgeterHost=st.nextToken();
try{
Sockets=newSocket(geterHost,SMTP_PORT);
PrintStreamout=newPrintStream(s.getOutputStream());
out.println("HELLO:"+senderHost);
/*邮件服务器不认证读者所输SMTP是不是准确*/
out.println("MAILFORM:"+senderName);
out.println("RCPTTO:"+geterName);
out.println("DATA");
out.println(memo);
out.println(".
QUIT");
MessageDialogmdlg=newMessageDialog(frame,"邮件地点准确","祝贺,您的邮件已乐成发送",1);
mdlg.show();}
catch(Exceptione){
System.out.println(e.toString());
MessageDialogmdlg=newMessageDialog(frame,"邮件发送失利",e.toString(),1);//"邮件发送堕落,请确认合从头发送!",1);
mdlg.show();
return;}
}//endofsendMail()
voidbutton1_actionPerformed(ActionEvente){
sendMail();
textArea1.setText("");}
voidbutton2_actionPerformed(ActionEvente){
textField1.setText("");
textFIeld2.setText("");
textArea1.setText("");}
}//endofMailApplet
classMailApplet_button1_actionAdapterimplementsjava.awt.event.ActionListener{
MailAppletadaptee;
MailApplet_button1_actionAdapter(MailAppletadaptee){
this.adaptee=adaptee;}
publicvoidactionPerformed(ActionEvente){
adaptee.button1_actionPerformed(e);}
}//endofthis
classMailApplet_button2_actionAdapterimplementsjava.awt.event.ActionListener{
MailAppletadaptee;
MailApplet_button2_actionAdapter(MailAppletadaptee){
this.adaptee=adaptee;}
publicvoidactionPerformed(ActionEvente){
adaptee.button2_actionPerformed(e);}
}//endofthis
再说第三点:我并没有提到服务器也要整合,然后是IDE,一个好的IDE能够200%提高开发的速度,就说图形方面:你是经过简单托拽和点击就能实现功能好那。 |
|