如何做百度输入框智能化搜索? 如何做百度输入框智能化搜索?文本框中输入信息查询数据库某一个字段相应的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 难道你说的是搜索提示功能?我的资源共享里有我用ajax结合数据库实现的搜索提示功能的例子。 import java.awt.*;import java.awt.event.*;import java.net.*;import java.io.*;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.net.*;import java.io.*;public class UrlConnect { public static void main(String[] args) { new NetWin(); }}class NetWin extends JFrame implements ActionListener, Runnable { JButton button; URL url; JTextField text; JEditorPane area; byte b[] = new byte[118]; Thread thread; String URL = "http://www.baidu.com/s?wd="; String fin; private Color white; NetWin() { text = new JTextField(20); area = new JEditorPane(); button = new JButton("查询"); button.addActionListener(this); thread = new Thread(this); JPanel p = new JPanel(); p.add(new JLabel("连接百度,请输入关键字:")); p.add(text); p.add(button); p.setBackground(white); add(area, BorderLayout.CENTER); add(p, BorderLayout.NORTH); setBounds(60, 60, 600, 400); setVisible(true); validate(); } public void actionPerformed(ActionEvent e) { if (!(thread.isAlive())) thread = new Thread(this); try { thread.start(); } catch (Exception ee) { text.setText("我正在读取" + url); } } public void run() { try { int n = -1; area.setText(null); area.setVisible(true); fin = text.getText(); URL += fin; url = new URL(URL); InputStream in = url.openStream(); while ((n = in.read(b)) != -1) { String s = new String(b, 0, n); area.setPage(URL); } } catch (MalformedURLException e1) { text.setText("" + e1); return; } catch (IOException e1) { text.setText("" + e1); return; } }} 这个是ajax做的技术叫autocomplate 楼主到搜索引擎上去搜索一下“Ajax 自动完成”就能找到很多的东西。如果想深入了解的话,建议看看这本书: 我想看一个例子java的 不是。net的 java中为什么子类仍然可以通过继承公共方法访问父类的私有变量? 关于synchronized(this)的问题? 类型转换问题 java threads , concurrency event etc.............. 不给分就没人回答我的问题吗??/ 请教关于UDP SOCKET丢包的问题 java那个控件能够实现多行文本不同颜色显示 用swing做飞机游戏的两个问题 我还是无法运行我的第一个程序/ 在java中,各鍵对应的代码为什么? 继承问题 打了一个ZIP包,怎么能把这个ZIP包当成一个文件,再打进一个ZIP包呢?然后在递归的解开!我有单层的源码可以直接运行
我的资源共享里有我用ajax结合数据库实现的搜索提示功能的例子。
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;public class UrlConnect { public static void main(String[] args) {
new NetWin();
}}class NetWin extends JFrame implements ActionListener, Runnable {
JButton button;
URL url;
JTextField text;
JEditorPane area;
byte b[] = new byte[118];
Thread thread;
String URL = "http://www.baidu.com/s?wd=";
String fin; private Color white; NetWin() {
text = new JTextField(20);
area = new JEditorPane();
button = new JButton("查询");
button.addActionListener(this);
thread = new Thread(this);
JPanel p = new JPanel();
p.add(new JLabel("连接百度,请输入关键字:"));
p.add(text);
p.add(button);
p.setBackground(white);
add(area, BorderLayout.CENTER);
add(p, BorderLayout.NORTH);
setBounds(60, 60, 600, 400);
setVisible(true);
validate();
} public void actionPerformed(ActionEvent e) {
if (!(thread.isAlive()))
thread = new Thread(this);
try {
thread.start();
} catch (Exception ee) {
text.setText("我正在读取" + url);
}
} public void run() {
try {
int n = -1;
area.setText(null);
area.setVisible(true);
fin = text.getText();
URL += fin;
url = new URL(URL);
InputStream in = url.openStream();
while ((n = in.read(b)) != -1) {
String s = new String(b, 0, n);
area.setPage(URL);
}
} catch (MalformedURLException e1) {
text.setText("" + e1);
return;
} catch (IOException e1) {
text.setText("" + e1);
return;
}
}}