1 14 package org.compiere.util; 15 16 import java.awt.BorderLayout ; 17 import java.awt.Dimension ; 18 import java.net.URL ; 19 20 import javax.swing.JDialog ; 21 import javax.swing.JEditorPane ; 22 import javax.swing.JScrollPane ; 23 24 import org.compiere.plaf.CompierePLAF; 25 26 32 public class MiniBrowser extends JDialog 33 { 34 37 public MiniBrowser() 38 { 39 this (null); 40 } 42 46 public MiniBrowser(String url) 47 { 48 this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 49 try 50 { 51 jbInit(); 52 } 53 catch(Exception e) 54 { 55 e.printStackTrace(); 56 } 57 setURL (url); 58 CompierePLAF.showCenterScreen(this); 59 } 61 private JScrollPane scrollPane = new JScrollPane (); 62 private JEditorPane editorPane = new JEditorPane (); 63 64 68 private void jbInit() throws Exception 69 { 70 scrollPane.setPreferredSize(new Dimension (500, 500)); 71 this.getContentPane().add(scrollPane, BorderLayout.CENTER); 72 scrollPane.getViewport().add(editorPane, null); 73 } 75 79 private void setURL (String url) 80 { 81 String myURL = url; 82 if (url == null) 83 myURL = "http://www.compiere.org"; 84 this.setTitle(myURL); 85 86 URL realURL = null; 88 try 89 { 90 realURL = new URL (myURL); 91 } 92 catch (Exception e) 93 { 94 System.err.println("MiniBrowser.setURL (set) - " + e.toString()); 95 } 96 if (realURL == null) 97 return; 98 99 try 101 { 102 editorPane.setPage(realURL); 103 } 104 catch (Exception e) 105 { 106 System.err.println("MiniBrowser.setURL (open) - " + e.toString()); 107 } 108 } } | Popular Tags |