/* (@)HTMLFun.java */
/* Copyright 2009 Sebastian Haufe
* Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
[url]http://www.apache.org/licenses/LICENSE-2.0[/url]
* Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
package com.ebenius;
import java.io.IOException;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.ImageView;
public class HTMLFun {
/**
* Test main method.
*
* @param args ignored
* @throws IOException
*/
public static void main(String[] args) throws IOException {
final JEditorPane editor = new JEditorPane();
editor.setEditorKit(new HTMLEditorKit() {
/** Serial version UID */
private static final long serialVersionUID = 1L;
ViewFactory myViewFactory = null;
@Override
public ViewFactory getViewFactory() {
final ViewFactory superViewFactory = super.getViewFactory();
return myViewFactory == null ? new ViewFactory() {
public View create(Element elem) {
final View view = superViewFactory.create(elem);
if (view instanceof ImageView) {
return new GlyphView(elem);
}
return view;
}
} : myViewFactory;
}
});
editor.setPage("http://www.heise.de");
final JFrame f = new JFrame("Test Frame: HTMLFun"); //$NON-NLS-1$
f.setContentPane(new JScrollPane(editor));
f.pack();
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setVisible(true);
}
}