import javax.swing.*;
import java.awt.*;
public class Explorer extends JFrame implements Runnable{
private JEditorPane browser=JEditorPane("text/html","");
private JScrollPane browserScroll;
private String html;
private Thread t;
public Explorer(){
super("Explorer");
Container cp=getContentPane();
browserScroll=new JScrollPane(browser);
cp.add(browserScroll);
pack()
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void setHTML(String str){
html=str;
t=new Thread(this);
t.start();
}
public void run() {
browser.setText(html);
}
public static void main(String[] args){
Explorer explorer=new Explorer();
explorer.setHTML(htmlpage);
}
}
假如int length=htmlpage.length()很长的话,比如大于50000,那么这个程序将运行的非常慢,巨慢!!
如何提高这个程序的性能
import java.awt.*;
public class Explorer extends JFrame implements Runnable{
private JEditorPane browser=JEditorPane("text/html","");
private JScrollPane browserScroll;
private String html;
private Thread t;
public Explorer(){
super("Explorer");
Container cp=getContentPane();
browserScroll=new JScrollPane(browser);
cp.add(browserScroll);
pack()
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void setHTML(String str){
html=str;
t=new Thread(this);
t.start();
}
public void run() {
browser.setText(html);
}
public static void main(String[] args){
Explorer explorer=new Explorer();
explorer.setHTML(htmlpage);
}
}
假如int length=htmlpage.length()很长的话,比如大于50000,那么这个程序将运行的非常慢,巨慢!!
如何提高这个程序的性能
中的htmlpage是什么啊?
没说明吧你
htmlpage不就是指String类型吗?setHTML(String str)只接收String类型;
这你都没有看出来啊,真是不好说你了. . .
2、explorer.setHTML(htmlpage); htmlpage没有定义
3、int length=htmlpage.length() 又是什么意思?
4、布局不合理