Skip to main content

JXEditorPane ?flush?

3 replies [Last post]
Anonymous

hey -

periodically i get a message that is pumped to a JXEditorPane (i
know because i hear the msg via freetts) yet they don't appear via on the
editor pane for sometime. it is as if i need flush, revalidate, or something.

here's a code stub:

private void insertText(JXEditorPane ep, String s, int index) {
EditorKit ek = ep.getEditorKit();
Document d = ep.getDocument();
final Point p = calculateScrollerPosition();
boolean isValid = false;

try {
if (ek instanceof HTMLEditorKit) {
((HTMLEditorKit)ek).insertHTML((HTMLDocument)d, index, s, 0,
0, null);
} else if (ek instanceof DefaultEditorKit) {
((DefaultEditorKit)ek).read(new StringReader(s), d, index);
}

isValid = true;
} catch (IOException ioe) {}
catch (BadLocationException ble) {}

if (isValid) {
ep.setCaretPosition(Math.min(index + s.length(), d.getLength()));

EventQueue.invokeLater(new Runnable() {
public void run() {
adjustScroller(p);
}
});
}
}

any/all ideas are appreciated,

- james

--
Java == platform independence
XML == application independence
JXTA == network independence

Secure End-to-End Computing

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
James Todd

Hi -

Is there a means to obtain a hook on the underlying JTreeCellRenderer for
JXTreeTable?

I have an application whereby the leaf nodes vary at time and as such I need
to be able to conditionally vary the respective icons.

thx,

- james

James Todd :: blogs.sun.com/gonzo

Java == platform independence
XML == application independence
JXTA == network independence

Secure End-to-End Computing

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

charles.armstrong
Offline
Joined: 2006-02-17
Points: 0

James,

I am by no means an expert in Editor Panes so I stand ready to be corrected by one of the Swing team.

However in my experience the best method for inserting text is the insertString method in javax.swing.text.Document

If it is inappropriate to use that or you find its behaviour
is no more predictable then it might be a threading issue (low priority thread etc.)

hth,
Charles.

James Todd

Agreed. Here's what I ended up doing, and it looks to be working. I had to comment
out the "reader flush" as it was throwing a exception each and every time that I
couldn't figure out how to address. Adding in the JXEditor repaint() and revalidate()
calls, admittedly a stab, seems to have done the trick though, fingers crossed.

rock on,

- james

private void update(JXEditorPane ep) {
/*
Document d = ep.getDocument();

if (d instanceof HTMLDocument) {
try {
((HTMLDocument)d).getReader(0).flush();
} catch (BadLocationException ble) {
}
}
**/

ep.revalidate();
ep.repaint();
}

Java == platform independence
XML == application independence
JXTA == network independence

Secure End-to-End Computing

jdnc-interest@javadesktop.org wrote:
> James,
>
> I am by no means an expert in Editor Panes so I stand ready to be corrected by one of the Swing team.
>
> However in my experience the best method for inserting text is the insertString method in javax.swing.text.Document
>
> If it is inappropriate to use that or you find its behaviour
> is no more predictable then it might be a threading issue (low priority thread etc.)
>
> hth,
> Charles.
> ---
> [Message sent by forum member 'charles.armstrong' (Charles Armstrong)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=33252&#33252
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
> For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net