怎样用java实现浏览器? 那就需要些一个能解释asp代码的server。类似一个虚拟机。但是这么做没什么意义。肯定不会比微软的iis快。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不明白,只是想做个浏览器,怎么会和server有关?有人告诉我说用eclipse swt 的browser可以实现,正在学eclipse中…… 对asp不能正常显示? 应该不会吧这类文件都是先解释过再由服务端发送到客户端来的,相当于html一样你是不是你他看你本机的 asp 文件,而本机的服务器没开?//错了不要劈偶 浏览器是客户端的,即使ie也只能解释html和jsasp和jsp,php,cgi等等一样,都是服务器端执行的程序你想解释asp,那就是写服务器端了 import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import java.net.URL;import javax.swing.text.*;import javax.swing.text.html.*;import java.io.*;public class HtmlBrower extends JFrame implements ActionListener,HyperlinkListener{ Container contentpane; JLabel labelprompt = new JLabel("ÇëÊäÈëURL"); JPanel jpanelmain = new JPanel(new GridBagLayout()); JTextField textfieldurl = new JTextField(10); JEditorPane jeditorpane = new JEditorPane(); public HtmlBrower() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { contentpane = this.getContentPane(); textfieldurl.addActionListener(this); jeditorpane.setEditable(false); jeditorpane.addHyperlinkListener(this); int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp = new JScrollPane(jeditorpane,v,h); jpanelmain.add(labelprompt,new GridBagConstraints(0,0,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE, new Insets (0,0,0,0),0,0)); jpanelmain.add(textfieldurl,new GridBagConstraints(0,1,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL, new Insets (0,0,0,0),0,0)); jpanelmain.add(jsp,new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.WEST,GridBagConstraints.BOTH, new Insets (0,0,0,0),0,0)); contentpane.add(jpanelmain,BorderLayout.CENTER); setTitle("mini IE"); setSize(600,500); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } public void actionPerformed(ActionEvent ae) { try { String str_url = textfieldurl.getText().trim(); if (!str_url.startsWith("http://www.")) { if (str_url.startsWith("www.")) { str_url = "http://"+str_url; } else str_url = "http://www."+str_url; } jeditorpane.setPage(str_url); } catch(IOException ioe) { JOptionPane.showMessageDialog(this,"URL µØÖ·²»ÕýÈ·£º "+textfieldurl.getText().trim(),"ÊäÈë²»ÕýÈ·",JOptionPane.ERROR_MESSAGE); } } public void hyperlinkUpdate(HyperlinkEvent hle) { if (hle.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { jeditorpane.setPage(hle.getURL()); } catch (IOException t) { JOptionPane.showMessageDialog(this,"´ò¿ªÁ¬½Óʧ°Ü!","ÊäÈë²»ÕýÈ·",0); t.printStackTrace(); } } } public static void main(String[] args) { new HtmlBrower(); }}楼上的 ,这样写确实不能正常打开 sina 163 chinaren 网 在java自动生成hashCode代码问题? 请大神赐教 jdbc封装问题,请大侠帮忙 关于串的一个又小由简单的问题 哪个开发环境比较好?eclipse?jbuilder?还是.............? jdk安装 一个I/O问题,比较特殊的文件 请教有关参数的问题 谁能告诉我???(!!!) 100分快来拿,TOMCAT的基本配置问题 java数组的一些小白问题? 请问这个程序错在哪里?? 关于用java写游戏动画的疑问
有人告诉我说用eclipse swt 的browser可以实现,正在学eclipse中……
这类文件都是先解释过再由服务端发送到客户端来的,相当于html一样你是不是你他看你本机的 asp 文件,而本机的服务器没开?//错了不要劈偶
asp和jsp,php,cgi等等一样,都是服务器端执行的程序
你想解释asp,那就是写服务器端了
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.net.URL;
import javax.swing.text.*;
import javax.swing.text.html.*;
import java.io.*;
public class HtmlBrower extends JFrame implements ActionListener,HyperlinkListener
{
Container contentpane;
JLabel labelprompt = new JLabel("ÇëÊäÈëURL");
JPanel jpanelmain = new JPanel(new GridBagLayout());
JTextField textfieldurl = new JTextField(10);
JEditorPane jeditorpane = new JEditorPane();
public HtmlBrower()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
contentpane = this.getContentPane();
textfieldurl.addActionListener(this);
jeditorpane.setEditable(false);
jeditorpane.addHyperlinkListener(this);
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(jeditorpane,v,h);
jpanelmain.add(labelprompt,new GridBagConstraints(0,0,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,
new Insets (0,0,0,0),0,0));
jpanelmain.add(textfieldurl,new GridBagConstraints(0,1,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,
new Insets (0,0,0,0),0,0));
jpanelmain.add(jsp,new GridBagConstraints(0,2,1,1,1,1,GridBagConstraints.WEST,GridBagConstraints.BOTH,
new Insets (0,0,0,0),0,0));
contentpane.add(jpanelmain,BorderLayout.CENTER);
setTitle("mini IE");
setSize(600,500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true); }
public void actionPerformed(ActionEvent ae)
{
try
{
String str_url = textfieldurl.getText().trim();
if (!str_url.startsWith("http://www."))
{
if (str_url.startsWith("www."))
{
str_url = "http://"+str_url;
}
else
str_url = "http://www."+str_url;
}
jeditorpane.setPage(str_url);
}
catch(IOException ioe)
{
JOptionPane.showMessageDialog(this,"URL µØÖ·²»ÕýÈ·£º "+textfieldurl.getText().trim(),"ÊäÈë²»ÕýÈ·",JOptionPane.ERROR_MESSAGE);
}
}
public void hyperlinkUpdate(HyperlinkEvent hle)
{
if (hle.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
try
{
jeditorpane.setPage(hle.getURL());
}
catch (IOException t)
{
JOptionPane.showMessageDialog(this,"´ò¿ªÁ¬½Óʧ°Ü!","ÊäÈë²»ÕýÈ·",0);
t.printStackTrace();
}
} }
public static void main(String[] args)
{
new HtmlBrower();
}
}
楼上的 ,这样写确实不能正常打开 sina 163 chinaren 网