JTextPane text-color change lagging
Hey all,
I'm using a JTextPane to generate HTML documents. I'm using a color-picker to set the text color, but the way I'm dispatching actions is causing the color change to lag one event. I know why it's doing this, I just can't think of a workaround. Any ideas?
Here's the code:
//On initialization of the color chooser:
textColorer.addActionListener(new StyledEditorKit.ForegroundAction("Change Color", textColorer.getColor()));
textColorer.addActionListener(new java.awt.event.ActionListener()
{
publicvoid actionPerformed(ActionEvent evt)
{
textColorerActionPerformed(evt);
}
});
//and the textColorerActionPerformed method:
privatevoid textColorerActionPerformed(ActionEvent evt)
{
ActionListener[] l = textColorer.getListeners(ActionListener.class);
if(l.length > 0)
{
for(int i = 0; i < l.length; i++)
textColorer.removeActionListener(l[i]);
}
textColorer.addActionListener(new StyledEditorKit.ForegroundAction("Color Text", textColorer.getColor()));
}
Any help would be appreciated!
Have a great Sunday,
Joe
[1838 byte] By [
Joe_ha] at [2007-11-27 8:39:00]

If you want help in the future then you should be responding to old posting before making new postings:
http://forum.java.sun.com/thread.jspa?threadID=5187912
Also, Swing related questions should be posted in the Swing forum.
> I'm using a color-picker to set the text color,
Well, I don't see any code here related to invoking and choosing the color. That is where you should be building the new ForegroundAction.
> and the points I rewarded (to you) I feel adequately indicated that the question had
Points? No idea what you are talking about.
You respond to a posting to indicate that you have read the posting and state whether the suggtestion helped or not. That way people don't waste time reading a posting that already has an answer.
> No need to get snippy. I try to utilize good posting etiquette,
No need to take it personal. You aren't following the normal forum etiquette, so I reminded you.
So I will remind you again, where in this posting have you indicated whether the suggestion worked or not?
> >If you want help in the future then you should be
> responding to old posting before making new
> postings:
>
> No need to get snippy. I try to utilize good posting
> etiquette, and the points I rewarded (to you) I feel
> adequately indicated that the question had been
> answered.
There was nothing snippy in his reply; he was just relaying info about forum etiquette that you may not have known previously.
Hey,
Sorry about that. I misunderstood the spirit of the post. I'll keep the suggestions in mind in the future.
>Points? No idea what you are talking about.
I virtually always attach Duke stars to questions. The thread I didn't follow up on I just rewarded the stars
Anyway, thanks for the response.
Joe
Joe_ha at 2007-7-12 20:36:46 >
