I'm creating a slider bar, which will be a subclass of JSlider, as part of a logging gui. What I'd like to do is be able to draw some items above the slider bar (e.g. a "volume" display, indicating how much logging info will be spit out by a particular setting). I have overridden the paintComponent() method, but I'm getting a bit confused about how the clipping rectangle is calculated for the Graphics object that is passed in to paintComponent.
Basically, what I want to do is create more space within the visible area of the component that can be drawn, but only ABOVE what is already drawn. So, for example, in the following image I have three slider bars:
The clipping rectangle is shown in red for each of these. (These are somewhat hand-drawn, but I did actually use the drawRect(g.getClipBounds()) and came up with similar rectangles. The top slider bar is what I get if I don't augment the slider bar at all. The middle rectangle is what I get if I override getPreferredSize() to add some amount (I call it the 'volume height' - by default, 20) to the height of the component. The bottom image is the one I want. Basically, it's the middle slider bar, but with the clipping rectangle translated by 1/2 the volume height toward the top of the component.
So, my question is 'How are clipping rectangles computed within the Graphics object when passed in to a paintComponent() method?' I can't seem to find out how the system determines what the clipping bounds should be for a given component.
Thanks,
~Scott