import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
class MyIEByGUI
{
private Frame f;
private TextField tf;
private Button but;
private TextArea ta;
private Dialog d;
private Label lab;
private Button okBut;
MyIEByGUI()
{
init();
}
public void init()
{
f = new Frame("my window");
f.setBounds(300,100,600,500);
f.setLayout(new FlowLayout());
tf = new TextField(60);
but = new Button("转到");
ta = new TextArea(25,70);
d = new Dialog(f,"提示信息-self",true);
d.setBounds(400,200,240,150);
d.setLayout(new FlowLayout());
lab = new Label();
okBut = new Button("确定");
d.add(lab);
d.add(okBut);
f.add(tf);
f.add(but);
f.add(ta);
myEvent();
f.setVisible(true);
}
private void myEvent()
{
okBut.addActionListener(new ActionListener()//对话框中的确定按钮
{
public void actionPerformed(ActionEvent
e)//点击对话框中的确定按钮,关闭对话框
{
d.setVisible(false);
}
});
d.addWindowListener(new WindowAdapter()//对话框
{
public void windowClosing(WindowEvent e)//添加对话框
{
d.setVisible(false);
}
});
tf.addKeyListener(new KeyAdapter()//文本框
{
public void keyPressed(KeyEvent e)
{
try
{
if(e.getKeyCode()==KeyEvent.VK_ENTER)//文本框中按下回车键,显示
showDir();
}
catch (Exception ex)
{
}
}
});
but.addActionListener(new ActionListener()//窗口中的转到按钮
{
public void actionPerformed(ActionEvent e)
{
try
{
showDir();//显示目录
}
catch (Exception ex)
{
}
}
});
f.addWindowListener(new WindowAdapter()//窗口
{
public void windowClosing(WindowEvent e)//点击关闭按钮
{
System.exit(0);
}
});
}
private void showDir()throws Exception
{
*");
out.println("Accept-Language: zh-cn");
out.println("Host: 192.168.1.254:11000");
out.println("Connection: closed");
out.println();
out.println();
BufferedReader bufr = new BufferedReader(new
InputStreamReader(s.getInputStream()));//读取 Tomcat返回的数据
String line = null;
while((line=bufr.readLine())!=null)
{
ta.append(line+"\r\n");//显示在文本区域中
}
s.close();
*/
//URL运用应用层的HTTP协议
ta.setText("");
String urlPath =
tf.getText();//http://192.168.1.254:8080/myweb/demo.html
URL url = new URL(urlPath);
URLConnection conn = url.openConnection();
InputStream in = conn.getInputStream();
}
public static void main(String[] args)
{
new MyIEByGUI();
}
}