黑马程序员技术交流社区
标题:
我的IE
[打印本页]
作者:
季995
时间:
2015-9-3 11:32
标题:
我的IE
求指教!!!!!!!
package cn.awt.fram;
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
public class MyIEGUI {
/**
* @param args
*/
public static void main(String[] args) {
init();
}
private static void init() {
Frame f;
f = new Frame();
f.setSize(400, 400);
f.setLocation(400, 100);
f.setLayout(new FlowLayout());
final TextField tf;
tf = new TextField(40);
Button but;
but = new Button();
but.setLabel("转到");
final TextArea ta;
ta = new TextArea(25, 50);
f.add(tf);
f.add(but);
f.add(ta);
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
but.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
try {
String tfx = tf.getText();// 获取文本框信息
int c1 = tfx.indexOf("//") + 2;
int c2 = tfx.indexOf("/", c1);
String str1 = tfx.substring(c1, c2);
String[] arr = str1.split(":");
int port=Integer.parseInt(arr[1]);
// System.out.println (url);///docs/1.html
// System.out.println (str1);//192.168.0.3:8080
String url = tfx.substring(c2, tfx.length());
Socket s=new Socket(arr[0],port);
PrintWriter out=new PrintWriter(s.getOutputStream(),true);
out.println("GET "+url+" HTTP/1.1");
out.println("Accept:*/*");
out.println("Accept-Language: zh-cn");
out.println("Host: 192.168.0.3:10009");
out.println("Connection: close");
out.println();
out.println();
BufferedReader buf=new BufferedReader(new InputStreamReader(s.getInputStream()));
String line=null;
while((line=buf.readLine())!=null){
ta.append(line+"\r\n");
}
} catch (Exception e1) {
throw new RuntimeException();
}
}
});
}
}
作者:
ln0491
时间:
2015-9-3 12:27
swing吗?。。。。。。。。。
作者:
季995
时间:
2015-9-3 14:05
ln0491 发表于 2015-9-3 12:27
swing吗?。。。。。。。。。
是的,类似于百度的程序,开启tomcat服务器
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2