Skip to main content

Nimbus and custom painters for a JSpinner

No replies
jeffproe
Offline
Joined: 2008-06-28
Points: 0

I'm using Nimbus L&F for a project. While I generally like the look of everything, I would like to make the visual cues that a JSpinner has focus a little more apparent. I'm trying to add a custom painter to a spinner with no luck. I'm hoping someone can give me some insight here. Here's what I've done so far:

UIDefaults defSpinner = new UIDefaults();

defSpinner.put( "Spinner:Panel:\"Spinner.formattedTextField\"[Enabled].backgroundPainter", new PainterSpinnerBackgroundEnabled() );

defSpinner.put( "Spinner:Panel:\"Spinner.formattedTextField\"[Focused].backgroundPainter", new PainterSpinnerBackgroundFocused() );

defSpinner.put( "Spinner:Panel:\"Spinner.formattedTextField\"[Focused+Selected].backgroundPainter", new PainterSpinnerBackgroundFocused() );

defSpinner.put( "Spinner:Panel:\"Spinner.formattedTextField\"[Selected].backgroundPainter", new PainterButtonBackgroundFocused() );

spn.putClientProperty( "Nimbus.Overrides", defSpinner );

spn.putclientProperty( "Nimbus.Overrides.InheritDefaults", false );
PainterSpinnerBackgroundEnabled and PainterSpinnerBackgroundFocused are just two classes that implement Painter and, at this point, do some very simple FillRect, DrawRect stuff for now.
This very same type of code worked fine for my buttons, but not for the spinner. Anyone have any thoughts?
Thanks,
Jeff