那位高人知道如何用java显示HTML吗? 什么意思,没有懂是不是用Java写个浏览器啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不懂。 估计他的意思是用java写个浏览器 在JEditorPane中加载网页:import java.awt.*;import javax.swing.*;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Aaa { JFrame frame; JEditorPane editorPane; File file; String str; public Aaa() { file = new File("html/test.html"); str = file.getAbsolutePath(); str = "file:"+str; frame = new JFrame("JEditPane"); editorPane = new JEditorPane(); try { editorPane.setPage(str); } catch (IOException ex) { System.out.println("加载不成功!"); System.out.println("IOException: " + ex); } frame.getContentPane().add(editorPane, BorderLayout.CENTER); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }}); frame.setSize(100,260); frame.setVisible(true); } public static void main(String[] args) { Aaa aaa1 = new Aaa(); }}另外用JEditorPane的子类JTextPane也可以加载HTML页面,方法基本相同。 new JLabel("<html><b>bbbb</b></html>") 我不太明白楼主的意思但有一个开源项目JR应该对你有帮助。他可以将java代码转变为html其中的一个类可以做到,不知道是不是你想要的 java的兴起就是由于java做了一个浏览器 hotjava .楼主没听说过吗? 对java的历史知道太少了:) 多谢各位帮助,我也是今年8月底接触Java,觉得不错,mq612(理想)、 kypfos(政治面貌:一世清白) 讲的方法都很值得参考,只是不知道如何给他们加分啊! 请问Vector的 boolean add(E e) 和 void addElement(E obj) 方法有什么区别 ~1(1的补码是多少) 一个程序使用了hibernate那么它可以跨数据库么 运行JAVA程序出现的奇怪现象 匿名对象 不太明白collection容器的线程安全的概念,请高手指导一下 如何唤醒睡眠的线程 List合并相同项怎么做 这回麻烦了,帮帮忙吧! 关于SCOKET和线程,急!!! 网络编程的问题 十分简单的问题,成功立即结帐!
import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/public class Aaa {
JFrame frame;
JEditorPane editorPane;
File file;
String str;
public Aaa() {
file = new File("html/test.html");
str = file.getAbsolutePath();
str = "file:"+str;
frame = new JFrame("JEditPane");
editorPane = new JEditorPane();
try {
editorPane.setPage(str);
}
catch (IOException ex) {
System.out.println("加载不成功!");
System.out.println("IOException: " + ex);
}
frame.getContentPane().add(editorPane, BorderLayout.CENTER); frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}});
frame.setSize(100,260);
frame.setVisible(true);
}
public static void main(String[] args) {
Aaa aaa1 = new Aaa();
}}另外用JEditorPane的子类JTextPane也可以加载HTML页面,方法基本相同。
但有一个开源项目JR应该对你有帮助。
他可以将java代码转变为html
其中的一个类可以做到,不知道是不是你想要的