public class JTextPaneDemo extends JFrame
{
public JTextPaneDemo()
{
JTextPane tp=new JTextPane();
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(tp,v,h);
Container cp=getContentPane();
cp.add(jsp);
setSize(400,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
show();
try
{
URL myurl = new URL("http://www.baidu.com");
tp.setPage(myurl);
}catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
new JTextPaneDemo();
}
{
public JTextPaneDemo()
{
JTextPane tp=new JTextPane();
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp=new JScrollPane(tp,v,h);
Container cp=getContentPane();
cp.add(jsp);
setSize(400,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
show();
try
{
URL myurl = new URL("http://www.baidu.com");
tp.setPage(myurl);
}catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
new JTextPaneDemo();
}
}
实验后发现
对js 支持 不好 很多网页打开有问题