Where will the JSlider actually be painted?
I just looked a the source code from JSlider SourceCode and if found a lot of repaint()开发者_如何学Go's as expected, because of the Template Pattern. But my problem is i didn't find the paint method, which actually paints the JSlider.
Can anybody explain me how this component will be painted?
Swing components are typically painted by their associated UI class. The UI class is specific to each Look And Feel. This is how you get JSlider to have a "native" feel or even a custom feel on different platforms. Each Swing component has a UI class, JSlider has SliderUI which has several flavors such as: MetalSliderUI, WindowsSliderUI, and SynthSliderUI.
You didn't find a paint method in JSlider because the paint method is in the parent class, JComponent. JComponent's paint methods (paint, paintComponent, repaint, etc) do some setup but then delegates the work to the UI class, which is provided by JSlider. There is an entire method chain that takes place in Swing for correctly painting/sizing components.
If we knew what you were trying to do we might be able to help you out.
精彩评论