hi all,
i have an
applet that has HTMLEditorPane (StyledEditor basically). i want to enable users to select color of the fonts from the ColorChooser.
now, colorchooser can be initiated by either,
1. JColorChooser.showDialog() or
2. JColorChooser.cretaeDialog()
my requirement wants,
1. a user pops up a color dialog and selects a color via "custom color" option in my menu
2. presses OK on the color dialog
3. then the selection in the HTML editor becomes of that color
the problem i found is,
1. how i can override OK button listener in such a manner that sets the foreground of the StyledEditor to the color lastest choosen?
this is a problem because- to change font color in Styled Editor we have to use StyledEditor.ForegroundAction and that accepts Color argument. in my application we have to use JColorChooser.createDialog() as i want to override the default OK button listener thing.
but when i use createDialog() i have to pass the listener into that which should be something like-
JColorChooser.createDialog(parentFrame, "Color Chooser", true, new StyledEditorKit.ForegroundAction("Color", myColorChooser.getColor(), null);
i have to do this each time the "custom color" option is choosen. (basically i have put this on MenuItem's action for "custom color" option).
but if i do this then upon poping up a color dialog the default color (Say it is C) gets selected and so the ForegroundAction() gets that color. now, even if we change a color (say C1) in the dialogbox and press OK it will change the color to be the previously selected color (that is C in this case), right?? now, if we repeat this procedure, next time the default color is C1 hence even if we change the color on color dialogbox to be say C2 and press OK the font color would be C1....so on and so forth...
so the bottom line- "i get the 'latest-1' color selection from the color dialog everytime instead 'latest'"
i hope you understand my problem. i have not posted questions to swing forum as i am not a great user of swing so far...
i have a solution to this- "override the StyledEditorKit.ForegroundAction class" and that will work but i wanted to know if there is any other way of doing this...
regards
maulin.