This is a follow-up question of Swing change the JSpinner back and fore colors
It is not possible to only set the color of the arrows without overriding the paint
method. The reason is simply that the color for the arrows is the same color as the color that is used for the "shadows" of the buttons. So you could put the line
UIManager.getDefaults().put("controlDkShadow", Color.MAGENTA);
somewhere into your main
, but this would not only change the arrow colors, but also other elements' colors which actually should not be changed.
An ugly/hacky way to set this color only for a particular instance would be
private static void hackilySetColor(JSpinner spinner, Color color)
{
int n = spinner.getComponentCount();
for (int i=0; i<n; i++)
{
Component c = spinner.getComponent(i);
if (c instanceof BasicArrowButton)
{
try
{
Field field = BasicArrowButton.class.getDeclaredField("darkShadow");
field.setAccessible(true);
field.set(c, color);
field.setAccessible(false);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
but this uses reflection, is really an ugly hack, and still replaces the color of the "dark shadow" border of the buttons.
You'll be better off with an own UI for things like this (or ... just don't change the color at all - this seems rather useless for me anyhow...)