?? test1.java.bak
字號:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.applet.*;
import java.io.*;
public class Test1 extends Applet implements ActionListener{
Panel p1,p2,p3,p4; Label lb1,lb2,lb3;TextField tf1,tf2;Button bt1,bt2,bt3;
URL url;
Socket socket;
DataInputStream in;
DataOutputStream out;
URL url1,url2,url3;
String s;
public void init(){
Color c1=new Color(233,233,233);
s="http://127.0.0.1/Example2.html";
setBackground(c1);
p1=new Panel();p2=new Panel();p3=new Panel();p4=new Panel();
lb1=new Label("會員登陸"); lb2=new Label("會員:"); lb3=new Label("密碼:");
tf1=new TextField(20);tf2=new TextField(20); tf2.setEchoChar('*');
bt1=new Button("確 定");bt2=new Button("取 消");bt3=new Button("注 冊");
p1.setBackground(Color.lightGray);tf1.setBackground(Color.lightGray);tf2.setBackground(Color.lightGray);
bt1.setBackground(Color.lightGray);bt2.setBackground(Color.lightGray);bt3.setBackground(Color.lightGray);
setLayout(null);
add(p1);p1.setBounds(200,200,377,29);
add(p2);p2.setBounds(200,231,377,29);
add(p3);p3.setBounds(200,260,377,30);
add(p4);p4.setBounds(200,290,377,30);
p1.add(lb1);
p2.add(lb2);p2.add(tf1);
p3.add(lb3);p3.add(tf2);
p4.add(bt1);p4.add(bt2);p4.add(bt3);
bt1.addActionListener(this);
bt2.addActionListener(this);
bt3.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==bt3)
{try
{url=new URL(s);
}
catch(MalformedURLException g)
{ //tf1.setText("不正確的URL:"+url);
}
getAppletContext().showDocument(url);
}
else if(e.getSource()==bt2)
{tf1.setText("");tf2.setText("");}
else if(e.getSource()==bt1)
{String s1=null,s2=null,s3=null,s4=null;
int flag=0;
s3=tf1.getText();s4=tf1.getText();
try{ socket=new Socket("127.0.0.1",4567);
in=new DataInputStream(socket.getInputStream());
out=new DataOutputStream(socket.getOutputStream());
out.writeUTF("denglu");
System.out.println("發送了信息:denglu");
}
catch(IOException e1){System.out.println("Error:start"+e1);}
try
{
out.writeUTF(s3);
out.writeUTF(s4);
System.out.println("發送了以下信息:"+s3+" , "+s4);
}
catch(IOException e2){System.out.println("erro:__"+e2);}
while(true)
{
try
{
s1=in.readUTF();
System.out.println(s1);
}
catch(IOException e1){}
if(s1!=null)break;
}
if(s1.equals("yes"))flag=1;
if(flag==0)
{
try
{
url1=new URL("http://127.0.0.1/Example4.html");
}
catch(MalformedURLException e1){}
getAppletContext().showDocument(url1);
}
else {try
{
url3=new URL("http://127.0.0.1/Example2.html");
}
catch(MalformedURLException e3){}
getAppletContext().showDocument(url3);
}
}
}
public void paint(Graphics g) {
g.drawRect(199,199,378,121); g.drawLine(200,230,577,230);
}
}
//<applet code=Test1.class width=777 height=600></applet>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -