Виктор Кон,   vkBook, Java-Second

Класс webFrame



import java.io.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.net.*;

public class webFrame{
 public int ix,iy,iw,ih;

 public webFrame(String fn, int[] ia) throws IOException {
  ix=ia[0]; iy=ia[1]; iw=ia[2]; ih=ia[3];
  try{ URL fileUrl = new URL("file:" + fn);
   createInternalFrame(createEditorPane(fileUrl),fn);}
  catch(MalformedURLException e){}
 }

 public void createInternalFrame(Component c, String t){  
  final JInternalFrame ifr = new JInternalFrame(t,true,true,false,false);
         //resizable, closable, maximizable, iconifiable
  ifr.getContentPane().add(c);
  ifr.setSize(iw,ih); ifr.setLocation(ix,iy);
  MainForm.deskt.add(ifr); ifr.setVisible(true);
  try {ifr.setSelected(true);}catch(java.beans.PropertyVetoException e){}
 }

 public Component createEditorPane(URL u){  
  JEditorPane ep = new JEditorPane();  ep.setEditable(false);
  ep.addHyperlinkListener
  (new HyperlinkListener()
   {public void hyperlinkUpdate(HyperlinkEvent event)
    {if(event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
     {createInternalFrame(createEditorPane(event.getURL()),event.getURL().toString());
   }}}
  );
  try{ep.setPage(u);}catch(IOException e){ep.setText("Exception: " + e);}
  return new JScrollPane(ep);
 }
}

Hosted by uCoz