Closed GoogleCodeExporter closed 9 years ago
This is strange. The component should have its size already, unless there is
something wrong.
Can you send/paste me the whole code, instead of just the steps above?
Original comment by ayman.al...@gmail.com
on 30 Dec 2008 at 10:57
Original comment by ayman.al...@gmail.com
on 30 Dec 2008 at 10:57
In my project, I encountered the problem when dynamically adding or removing
JEditorPane in tabs of a JTabbedPane.
Please find attach the smallest piece of code that I was able to write in order
to
reproduce the NullPointerException. You have to click on the JButton in order to
generate the NPE.
P.S: thanks a lot for your wonderful piece of code!
Original comment by oste...@gmail.com
on 30 Dec 2008 at 1:06
Attachments:
I just fixed it in the latest release (r64). It missed the binary release by
just a
few minutes.
You also need to call the doLayout method on the container just after the add is
called. Otherwise it wont display immediately.
c.add(scrPane, BorderLayout.CENTER);
c.doLayout();
Original comment by ayman.al...@gmail.com
on 30 Dec 2008 at 1:39
I tried the latest release (r64). There is no more NPE. Unfortunately, there is
still
a problem, the lines are not correctly numbered. For instance, if you try to
execute
my previous TestIssue47 class while providing a multi-line content as parameter
of
the setText method (setText("xxx\nxxx\nxxx");), only the first line is numbered
;(.
Original comment by oste...@gmail.com
on 30 Dec 2008 at 3:21
In that case, maybe other things could fail. You should call the setContentType
after calling doLayout on the component. Let me know if that does not work.
Original comment by ayman.al...@gmail.com
on 30 Dec 2008 at 4:16
Unfortunately, it seems the problem is not related to the doLayout() as
illustrated
in the code attached to this comment. In this example, doLayout() is called
before
the setContentType(), and latter the setText() is called.
Original comment by oste...@gmail.com
on 30 Dec 2008 at 6:07
Attachments:
The problem is that the LineNumbersRuler component is a CaretListener, but the
Caret
is not moved by the initial setText. I implemented a CaretListener because at
time
of registering the LineNumbersRuler to the component, the Editor's
SyntaxDocument is
yet available.
I'll look at a better solution. Seems like listening for the components
propertyChange and implementing a DocumentListener will be needed.
Original comment by ayman.al...@gmail.com
on 31 Dec 2008 at 5:14
Fixed in r65. I did the above, and also don't call the modelToView, relying on
the
Document Elements now.
Many thanks for keeping me honest :-)
Original comment by ayman.al...@gmail.com
on 31 Dec 2008 at 8:12
It works like a charm !
Thank you very much for your effort and one more time thank you for providing
us such
a useful component.
Original comment by oste...@gmail.com
on 31 Dec 2008 at 9:12
Original issue reported on code.google.com by
oste...@gmail.com
on 24 Dec 2008 at 10:53