Writing text in two buffers
Submitted by Sunday, 28 March, 2010 - 13:31
on
Hi to all,
I'd like to write text in two new buffers, so I wrote this short beanshell script:
buffer1 = jEdit.newFile(view);
editPane = view.goToBuffer(buffer1);
textArea = editPane.getTextArea();
textArea.setSelectedText("Buffer 1\n");
buffer1.save(view, "C:/Work/test1", true);
buffer2 = jEdit.newFile(view);
editPane = view.goToBuffer(buffer2);
textArea = editPane.getTextArea();
textArea.setSelectedText("Buffer 2\n");
buffer2.save(view, "C:/Work/test2", true);
as soon as the script tries to execute the textArea.setSelectedText, I get an exception "Text component read only". Has anyone an idea why I get this exception?
Moving the buffer1.save downward to the buffer2.save the script works fine.
The next challenge: if I try to write in the buffers alternate (first in buffer1, next buffer2 and then in buffer1 again) all the text is written in just one buffer. how do I select where my text is written?
thanks in advance for your responses, Dirk
I'd like to write text in two new buffers, so I wrote this short beanshell script:
buffer1 = jEdit.newFile(view);
editPane = view.goToBuffer(buffer1);
textArea = editPane.getTextArea();
textArea.setSelectedText("Buffer 1\n");
buffer1.save(view, "C:/Work/test1", true);
buffer2 = jEdit.newFile(view);
editPane = view.goToBuffer(buffer2);
textArea = editPane.getTextArea();
textArea.setSelectedText("Buffer 2\n");
buffer2.save(view, "C:/Work/test2", true);
as soon as the script tries to execute the textArea.setSelectedText, I get an exception "Text component read only". Has anyone an idea why I get this exception?
Moving the buffer1.save downward to the buffer2.save the script works fine.
The next challenge: if I try to write in the buffers alternate (first in buffer1, next buffer2 and then in buffer1 again) all the text is written in just one buffer. how do I select where my text is written?
thanks in advance for your responses, Dirk