I'm using a JEditorPane and StyledDocument, which automatically wraps text to the window. I cannot have this, I need the window to allow horizontal scrolling of the text. I've been all over yahoo and google and cannot find an answer on how to disable word wrapping. And before anyone tells me to use JTextArea, I can't use that because I'm creating an IDE with syntax highlighting. Any help?

I've tried putting the editor in a JPanel with FlowLayout, but I didn't get the desired results.

Recommended Answers

All 5 Replies

Good luck fixing that. The ONLY thing I can think of trying is using a scrollpane and then adding the editorpane to that. If that doesn't work then I believe you are out of luck.

Already tried that too.

I've also run into another problem. Loading a new file into the editor seems to be very slow.
Is there another preferred way to load files into it?

File file = new File("c:/test/test.dba");
FileInputStream f = new FileInputStream(file);
editorPane.read(f, null);

A 4200 line file takes 5 or more seconds to load, even with no sytnax highlighting being done.

Can you try reading the data into a document and then setting the document of the editorpane?

Document.insertString(int offset, String str, AttributeSet a)

Not sure if doing it that way would be any faster though, cause I'm pretty sure thats what the editorPane calls anyway when reading in a file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.