Article View: borland.public.jbuilder.java.api
Article #2900Re: Examples for HTMLEditorKit
From: Alexander Anguiano
Date: Thu, 30 Jul 1998 00:00
Date: Thu, 30 Jul 1998 00:00
65 lines
2727 bytes
2727 bytes
Hello
this is an example of how to use the html JEditorpane.
I have found samples of the html stuff in Java Fondation Classes by Matthew
T. Nelson ( which is an excellent book on swing) also there is another book
Up with swing that I bought from CyberBooks and use it as the real swing
documentation) Bruce Eckel has another excellent book that you can download
from www.mindview.net/javabook.html that has html samples. One more, the
Swing connection on the sun sight has an example of the EditorKits.
note: using the "file:///" protocol displays files on you local hard drive
or network drives
you could also use "http:///" protocol that will connect you directly to the
internet. Also if you get any of the sources that I've suggested all of
them have examples of making the links work too.
private JPanel createPage(File file) {
JPanel result = new JPanel();
JEditorPane html;
result.setLayout( new BorderLayout() );
try {
// Load the URL we want to display
URL url = new URL( "file:///" + KnowledgeBaseToolkit.filesPath +
file.getName() );
// Create an HTML viewer to display the URL
html = new JEditorPane();
html.setPage(url);
String contentType = html.getEditorKit().getClass().getName();
html.setEditable( false );
JScrollPane scrollPane = new JScrollPane();
scrollPane.getViewport().add( html, BorderLayout.CENTER );
result.add( scrollPane, BorderLayout.CENTER );
}
catch( Exception e ) //MalformedURLException
{
System.out.println( "Malformed URL: " + e );
}
return result;
}
Editions Vigdor wrote in message <35BDEB54.2A136FA0@vigdor.com>...
>Hi !
>I am trying to write a software that will parse an html-like file and I
>assume that I could probably use the HTMLEditorKit class in the swing
>package, maybe with one or two patches. That is, if I manage to
>understand how it works.
>So : does anyone know where I could find some examples using this class
>?
>
>thanks in advance,
> David
>--
>�ditions
> num�riques scientifiques et universitaires
> VIGDOR
>
>exploration de textes
> par ordinateur
>
>http://www.vigdor.com
> contact@vigdor.com
Technical Details
Message-ID:
<6pqhga$n9a@bgtnsc02.worldnet.att.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35BDEB54.2A136FA0@vigdor.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 1089d0,465fc7d632f8f76a X-Google-Attributes: gid1089d0,public From: "Alexander Anguiano" <AlexAnguiano@worldnet.att.net> Subject: Re: Examples for HTMLEditorKit Date: 1998/07/30 Message-ID: <6pqhga$n9a@bgtnsc02.worldnet.att.net> X-Deja-AN: 376431654 References: <35BDEB54.2A136FA0@vigdor.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: AT&T WorldNet Services Newsgroups: borland.public.jbuilder.java.api