 
View Full Version : Java e html, posos inserirlo in un JFrame?
mcHorney
07-06-2003, 23:45
Ciao a tutti, con un amico sto sviluppando un' applicazione in java e fin qui tutto ok, solo che per diversi motivi la documentazione e l' help č stato fatto in html (usando i frame), ora mi domandavo č possible far visualizzare questa pagine htl all' interno della nostra applicazione, possibilmente dentro un jframe?
Grazie a tutti, Mc
Si puņ tutto!
Avete familiaritą con la classe JEditorPane?
import java.awt.*;
import javax.swing.*;
//import com.lightdev.app.shtm.SHTMLEditorPane;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;
public class MainWindow extends JFrame implements HyperlinkListener{
 // SHTMLEditorPane editor=new SHTMLEditorPane();
  JEditorPane editor=new JEditorPane();
  MainWindow() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    editor.setEditable(false);
    editor.addHyperlinkListener(this);
    try {
      editor.setPage("file:///f:/downloads/prova_frames.htm");
    } catch (Exception ex) {
      System.out.println(ex);
    }
    JScrollPane scroller=new JScrollPane(editor);
    getContentPane().setLayout(new GridLayout(1,1));
    getContentPane().add(scroller);
    setSize(600,300);
    show();
  }
  public void hyperlinkUpdate(HyperlinkEvent e) {
    if(e.getEventType()==HTMLFrameHyperlinkEvent.EventType.ACTIVATED) {
      HTMLFrameHyperlinkEvent he=(HTMLFrameHyperlinkEvent)e;
      try {
        //System.out.println(he.getTarget());
        HTMLDocument doc=(HTMLDocument)editor.getDocument();
        doc.processHTMLFrameHyperlinkEvent(he);
      }
      catch (Exception ex) {
        System.out.println(ex);
      }
    }
  }
  public static void main(String[] args) {
    new MainWindow();
  }
}
et voilą. Il supporto č fino all'HTML 3.2.
Ciao.
mcHorney
08-06-2003, 16:10
Grazie, ora mi studio il codice
Ciao, Mc
mcHorney
12-07-2003, 22:17
Mi hai risolto un megaproblema grazie mille
Ciao, Mc
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.