http://www.cn-java.com/target/news.php?news_id=1328
解决方案 »
- 怎么备份oracle,在服务器上面???
- 请推荐一本经典的入门级别的java语言编程的书。谢谢!
- 求一份java开发项目详细设计说明书实例
- java中递归读取树状表生成json字符串
- jsp 批量打印?
- 如何判断输入文本框中的值是否合法???(在线等)
- 为什么在MyEclipse下打开Tomcat就可以,单开Tomcat就不行呢?
- int rowCount = pstmt.executeUpdate(); 怎么不执行?
- 为什么总说找不到servlet类?
- 在j2se加win98下:"javax.servlet"找不到 是不是必须j2ee 而j2ee是不是必须win2000
- 关于SERVLET显示中文的问题
- 用jsp做过OA的朋友,请进!!
帮人都解决好几个了。
QQ:12318872
MAIL:[email protected]
public class SendApplet extends JApplet {
boolean isStandalone = false;
Label sendLabel=new Label();
Label messageInfo=new Label();
Button sendButton=new Button();
TextField sendText=new TextField();
TextField messageText=new TextField();
URLConnection connect;
String message;
URL chatURL;
XYLayout xYLayout1 = new XYLayout();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
} //Construct the applet
public SendApplet() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
sendLabel.setText("请输入信息:");
this.getContentPane().setLayout(xYLayout1);
messageInfo.setText("你输入的信息是:");
sendButton.setLabel("发送");
sendButton.addActionListener(new java.awt.event.ActionListener()
{public void actionPerformed(ActionEvent e){sendButton_actionPerformed(e);}
}
);
messageText.setEditable(false);
xYLayout1.setWidth(400);
xYLayout1.setHeight(129);
sendText.addActionListener(new java.awt.event.ActionListener()
{public void actionPerformed(ActionEvent e){sendText_actionPerformed(e);}
}
);
this.getContentPane().add(sendLabel, new XYConstraints(0,0,400,-1));
this.getContentPane().add(messageInfo, new XYConstraints(9,58,388,19));
this.getContentPane().add(sendText, new XYConstraints(6,24,205,-1));
this.getContentPane().add(sendButton, new XYConstraints(210,24,187,22));
this.getContentPane().add(messageText, new XYConstraints(5,89,400,-1));
chatURL=getCodeBase();
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
} //static initializer for setting look & feel
public synchronized void start()
{
}
public synchronized void stop()
{
}
public synchronized void destroy()
{
}
void Send()
{
message=sendText.getText();
sendText.setText("");
showStatus("Message sent!");
String queryString="servlettoapplet.ReceiveServlet?message=" + URLEncoder.encode(message);
try{
connect=(new URL(chatURL,queryString)).openConnection();
showStatus("Open Connection!");
connect.setDefaultUseCaches(false);
connect.setUseCaches(false);
connect.setDoInput(true);
connect.setDoOutput(false);
connect.connect();
showStatus("打开流");
DataInputStream in=new DataInputStream(connect.getInputStream());
showStatus("读数据");
message=in.readLine();
while(message!=null)
{
messageText.setText(message);
message=in.readLine();
}
}
catch(MalformedURLException e2)
{
System.err.println("MalformedURLException!");
e2.printStackTrace(System.err);
showStatus("MalformedURLException!");
}
catch(IOException e1)
{
System.err.println("IOException!");
e1.printStackTrace(System.err);
showStatus("IOException!");
}
}
public void sendButton_actionPerformed(ActionEvent e)
{
Send();
}
public void sendText_actionPerformed(ActionEvent e)
{
Send();
}
}