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
| try{
url = new URL("file", "localhost", f.getAbsolutePath());
JScrollPane editorScrollPane = null;
if(url != null){
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
editorPane.setPage(this.url);
editorPane.setFont(new java.awt.Font("Monospaced", 0, 10));
editorScrollPane = new JScrollPane(editorPane);
editorScrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
editorScrollPane.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
editorScrollPane.setPreferredSize(new Dimension(250, 145));
editorScrollPane.setMinimumSize(new Dimension(10, 10));
}
this.getContentPane().add(editorScrollPane);
this.setSize(new Dimension(500, 300));
this.show();
}
catch(Exception e){
System.out.println("Erreur affichage du fichier : "+e);
} |
Partager