1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
import java.awt.*;
import javax.swing.*;
import javax.swing.text.html.*;
public class Test extends JFrame
{
private static JEditorPane jEditorPane1=new JEditorPane("text/html","<html><body>");
private static JScrollPane jScrollPane1=new JScrollPane();
public Test()
{
super();
initialise();
this.setVisible(true);
}
private void initialise()
{
contentPane = (JPanel)this.getContentPane();
jEditorPane1.setEditable(true);
jScrollPane1.setViewportView(jEditorPane1);
contentPane.setLayout(null);
addComponent(contentPane, jScrollPane1, 64,26,651,488);
this.setTitle("Test");
this.setLocation(new Point(279, 197));
this.setSize(new Dimension(869, 680));
}
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
HTMLEditorKit kit = new HTMLEditorKit();
HTMLDocument doc = new HTMLDocument();
try
{
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (Exception ex)
{
System.out.println(ex);
}
new Test();
jEditorPane1.setEditorKit(kit);
jEditorPane1.setDocument(doc);
try
{
kit.insertHTML(doc, doc.getLength(), "<br>texte ici", 0, 0, HTML.Tag.BR);
}catch (Exception ex)
{ex.printStackTrace();}
}
} |
Partager