使用JEditorPane 显示WEB页面

import java.io.IOException;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;

/**
 * 使用JEditorPane 显示WEB页面
 * @author Vic
 *
 */
public class OreillyHomePage {
	public static void main(String[] args) {
		JEditorPane jep = new JEditorPane();
		jep.setEditable(false);
		
		try {
			jep.setPage("http://www.oreilly.com");
		} catch (IOException e) {
			jep.setContentType("text/html");
			jep.setText("<html>Could not load http://www.oreilly.com </html>");
		}
		
		JScrollPane scrollpane = new JScrollPane(jep);
		JFrame f = new JFrame("'0'Reilly & Associates");
		f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		f.setContentPane(scrollpane);
		f.setSize(512,342);
		f.show();
	}
}

你可能感兴趣的:(editor)