Java 什么容器可以执行HTML??? Java 什么容器可以执行HTML???Jlable除外。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 HTML是浏览器语言,跟java容器有毛个关系。 楼主表述的不清楚,不过我明白意思了JTextPane可以,swing的很多组件都可以 是不是父类是JCompent的都可以呢?有待我验证啊! JTextField应该不行JTextArea应该行 容器不知道 反正java Applet可以 JEditorPane容器可以解析HTML,但是HTML中的CSS样式解析不了 JEditorPane功能太弱了。不支持js脚本。基本只能显示静态页面。 public JTextPane mailContent;// 邮件内容的显示mailContent = new JTextPane();// 可以用以图形方式表示的属性来标记的文本组件 HTMLEditorKit kit = new HTMLEditorKit();// 新建HTMLEditorKit mailContent.setEditorKit(kit);// 设置EditorKit为HTMLEditorKit mailContent.setContentType("text/html");JTextPane 可以用来显示html文件 以URL类当作JEditPane的参数来构造,但是要注意的地方是使用这种方式来构造里,计算机要连接上局域网络或网际网络不然程序会找不到URL指定的位置而产生Exception使得程序无法动作.我们来看下面的范例吧!import javax.swing.*;import javax.swing.event.*;import java.awt.event.*;import java.net.*;import java.io.*;public class JEditorPane3{public static void main(String[] args){JEditorPane editPane=null;try{ URL address=new URL("http://www.sina.com.cn"); editPane=new JEditorPane(address); }catch(MalformedURLException e){ System.out.println("Malformed URL:"+e); }catch(IOException e){ System.out.println("IOException:"+e); } editPane.setEditable(false); JFrame f=new JFrame("JEditorPane3"); f.setContentPane(new JScrollPane(editPane)); f.setSize(200,250); f.show(); f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } });} } public JTextPane mailContent;mailContent = new JTextPane();// 可以用以图形方式表示的属性来标记的文本组件 HTMLEditorKit kit = new HTMLEditorKit();// 新建HTMLEditorKit mailContent.setEditorKit(kit);// 设置EditorKit为HTMLEditorKit mailContent.setContentType("text/html"); JTextPane 可以用来显示html文件 以URL类当作JEditPane的参数来构造,但是要注意的地方是使用这种方式来构造里,计算机要连接上局域网络或网际网络不然程序会找不到URL指定的位置而产生Exception使得程序无法动作.我们来看下面的范例吧! import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; import java.net.*; import java.io.*; public class JEditorPane3{ public static void main(String[] args){ JEditorPane editPane=null; try{ URL address=new URL("http://www.sina.com.cn"); editPane=new JEditorPane(address); }catch(MalformedURLException e){ System.out.println("Malformed URL:"+e); }catch(IOException e){ System.out.println("IOException:"+e); } editPane.setEditable(false); JFrame f=new JFrame("JEditorPane3"); f.setContentPane(new JScrollPane(editPane)); f.setSize(200,250); f.show(); f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); } } JEditorPanel 只支持 HTML 3.2 的东西,不支持目前使用最多的 HTML 4.01,更不支持 HTML 5 了。 如果啥都能做的话,那 JDK 还得先实现一个浏览器。 javafx 2.0 beta for windows里包含web组件 SOS~~关于applet数字签名的问题 小弟刚入门,请教一个小小问题! 字符串 初学者必遇经典问题 环境变量已经设置好了,在j2sdk1.4.2_08中可以编译的过去但是执行不了 Exception处理问题 请教关于JFreeChart的交互的问题。 苦恼了俩天的问题,关于JB连接ORACLE 在JavaMail中如何指定SMTP服务器的端口(如果不是缺省的25)? 大神们,小弟来了! 在不停止现有的业务上,如何完成数据库的更换,大家帮帮忙 java 包 "123".equals(name)和name.equals("123")的区别
public JTextPane mailContent;// 邮件内容的显示
mailContent = new JTextPane();// 可以用以图形方式表示的属性来标记的文本组件
HTMLEditorKit kit = new HTMLEditorKit();// 新建HTMLEditorKit
mailContent.setEditorKit(kit);// 设置EditorKit为HTMLEditorKit
mailContent.setContentType("text/html");
JTextPane 可以用来显示html文件 以URL类当作JEditPane的参数来构造,但是要注意的地方是使用这种方式来构造里,计算机要连接上局域网络或网际网络不然
程序会找不到URL指定的位置而产生Exception使得程序无法动作.我们来看下面的范例吧!import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;public class JEditorPane3{
public static void main(String[] args){
JEditorPane editPane=null;
try{
URL address=new URL("http://www.sina.com.cn");
editPane=new JEditorPane(address);
}catch(MalformedURLException e){
System.out.println("Malformed URL:"+e);
}catch(IOException e){
System.out.println("IOException:"+e);
}
editPane.setEditable(false);
JFrame f=new JFrame("JEditorPane3");
f.setContentPane(new JScrollPane(editPane));
f.setSize(200,250);
f.show();
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
}
public JTextPane mailContent;
mailContent = new JTextPane();// 可以用以图形方式表示的属性来标记的文本组件
HTMLEditorKit kit = new HTMLEditorKit();// 新建HTMLEditorKit
mailContent.setEditorKit(kit);// 设置EditorKit为HTMLEditorKit
mailContent.setContentType("text/html");
JTextPane 可以用来显示html文件 以URL类当作JEditPane的参数来构造,但是要注意的地方是使用这种方式来构造里,计算机要连接上局域网络或网际网络不然
程序会找不到URL指定的位置而产生Exception使得程序无法动作.我们来看下面的范例吧!
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.net.*;
import java.io.*; public class JEditorPane3{
public static void main(String[] args){
JEditorPane editPane=null;
try{
URL address=new URL("http://www.sina.com.cn");
editPane=new JEditorPane(address);
}catch(MalformedURLException e){
System.out.println("Malformed URL:"+e);
}catch(IOException e){
System.out.println("IOException:"+e);
}
editPane.setEditable(false);
JFrame f=new JFrame("JEditorPane3");
f.setContentPane(new JScrollPane(editPane));
f.setSize(200,250);
f.show();
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
}
如果啥都能做的话,那 JDK 还得先实现一个浏览器。