java浏览器代码 java script浏览器( 七 )


JOptionPane.showMessageDialog ((Component)null,muex.toString (),"网页浏览器",JOptionPane.ERROR_MESSAGE);
}
catch(Exception ex) {
JOptionPane.showMessageDialog ((Component) null,ex.toString (),"网页浏览器",JOptionPane.ERROR_MESSAGE);
}
}
};
thread.start ();
}
/*
**获得源代码
*/
void getHtmlSource (String url) {
String linesep,htmlLine;
linesep = System.getProperty ("line.separator");
htmlSource ="";
try {
java.net.URL source = new URL (url);
InputStream in = new BufferedInputStream (source.openStream ());
BufferedReader br = new BufferedReader ( new InputStreamReader (in));
while((htmlLine = br.readLine ())!=null) {
htmlSource = htmlSource +htmlLine+linesep;
}
}
catch(java.net.MalformedURLException muex) {
JOptionPane.showMessageDialog (WebBrowser.this,muex.toString (),"网页浏览器",JOptionPane.ERROR_MESSAGE);
}
catch(Exception e) {
JOptionPane.showMessageDialog (WebBrowser.this,e.toString (),"网页浏览器",JOptionPane.ERROR_MESSAGE);
}
}
/**
**实现监听器接口的hyperlinkUpdate函数
*/
public void hyperlinkUpdate (HyperlinkEvent e) {
/* if(e.getEventType () == HyperlinkEvent.EventType.ACTIVATED) {
String url = jurl.getText();
if(url.length ()0url.startsWith ("http://")) {
try {
jEditorPane1.setPage (url);
jEditorPane1.revalidate ();
}
catch(Exception ex) {
}
}
else if(url.length ()0!url.startsWith ("http://")) {
url="http://"+url;
try {
jEditorPane1.setPage (url );
jEditorPane1.revalidate ();
}
catch(Exception ex) {
}
}
}
*/
// Revised by copy editor :) Now with new code to help hyperlink
try {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
jEditorPane1.setPage(e.getURL());
} catch (Exception ex) {
ex.printStackTrace(System.err);
}
}
/*生成一个IE对象*/
public static void main (String [] args){
try{
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName()
);
}
catch(Exception e){
}
WebBrowser webBrowser = new WebBrowser ();
webBrowser.pack();
webBrowser.setVisible(true);
}
}
【java浏览器代码 java script浏览器】关于java浏览器代码和java script浏览器的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读