[SWING][JEditorPane] retour à la ligne automatiques
Bonjour,
Je veux afficher un fichier texte dans un JEditorPane. voici le code :
Code:
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);
} |
Le problème est que le fichier comporte des lignes assez longue et bien que j'ai mis :
Code:
1 2
| editorScrollPane.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); |
Le scrollbarre horizontal n'est jamais activé et le JEditorPane affiche une ligne sur plusieurs ligne.
A la place d'avoir :
Citation:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
j'ai :
Citation:
aaaaaa
aaaaaa
aaaaaa
aaaaaa
aaaaaa
comment faire pour empêcher ça ?
merci :)