I'm noticing something odd with JSpinner.
If I call setEditor on a JSpinner, I get a different font in the text
area than if I let the JSpinner create its own editor. For example, in
the metal laf, an editor set by setEditor is bold, while the font
remains plain for the editor created by default. In the windows laf,
setEditor gives a monospace font, while the default editor is in sans-
serif. However, I can override JSpinner.createEditor, create *exactly*
the same editor, and it looks like the normal editor (not bold or
monospace).
All of this is with 1.5. This is just a nuisance for me at this point,
since I've found a solution for the problem... but I'm wondering why
this would be true. Did I miss something here? It seems like a Swing
bug to me.
(I also tried an updateUI on the editor, and on its JFormattedTextField,
with no luck.)

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
> I'm noticing something odd with JSpinner.
>
[quoted text clipped - 14 lines]
> (I also tried an updateUI on the editor, and on its JFormattedTextField,
> with no luck.)
I found a similar anomaly, which is very likely to be related to the
setEditor anomaly that you found.
When creating a spinner in one step, like
jSpinner1 = new JSpinner(new SpinnerNumberModel(5, 0, 10, 1));
the font of the inputfield/editor is sans-serif normal (i.e. not bold).
However, creating the spinner first and then setting the model, like
jSpinner2 = new JSpinner();
jSpinner2.setModel(new SpinnerNumberModel(5, 0, 10, 1));
results in a sans-serif *bold* font.
Happens with 1.5.0 and default Java cross-platform L&F, but not with
1.4.2 (I didn't try other L&Fs).
I agree that it's probably a Swing bug (haven't searched bug database,
though).

Signature
Regards,
Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
Chris Smith - 14 Mar 2005 20:00 GMT
> However, creating the spinner first and then setting the model, like
>
> jSpinner2 = new JSpinner();
> jSpinner2.setModel(new SpinnerNumberModel(5, 0, 10, 1));
>
> results in a sans-serif *bold* font.
Yep, it seems like exactly the same bug. Unless you've already set an
editor explicitly, calling setModel calls setEditor, so again you've got
a setEditor call after the component is initially created -- albeit
inside of JSpinner instead of directly from your code.
This appears to be bug 6218764 on java.sun.com. It's possible that
5036022 is related, as well.
Thanks! I just wanted to be sure I wasn't missing anything.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation