public void paint(Graphics g) { // Calculate the slider position int sliderHeight = _imageSlider.getHeight(); int sliderBackYOffset = (_totalHeight - sliderHeight) >> 1; // Determine a Background Color for the slider int backgroundColor = _defaultBackgroundColour; if (_backgroundSelectedColours != null || _backgroundColours != null) { if (_selected) { backgroundColor = _backgroundSelectedColours != null ? _backgroundSelectedColours[getState()] : _defaultSelectColour; } else if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) { backgroundColor = _backgroundColours != null ? _backgroundColours[getState()] : _defaultHoverColour; } else { backgroundColor = _defaultBackgroundColour; } } g.setColor(backgroundColor); g.fillRect(1, sliderBackYOffset + 1, _totalWidth - 2, sliderHeight - 2); if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) { paintSliderBackground( g, _imageSliderFocusLeft, _imageSliderFocusCenter, _imageSliderFocusRight); } else { paintSliderBackground(g, _imageSliderLeft, _imageSliderCenter, _imageSliderRight); } // Calculate the thumb position int thumbXOffset = ((_totalWidth - _thumbWidth) * _currentState) / _numStates; // Draw the thumb g.drawBitmap( thumbXOffset, (_totalHeight - _thumbHeight) >> 1, _thumbWidth, _thumbHeight, _imageThumb, 0, 0); }
protected void drawFocus(Graphics g, boolean on) { boolean oldDrawStyleFocus = g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS); try { if (on) { g.setDrawingStyle(Graphics.DRAWSTYLE_FOCUS, true); } paint(g); } finally { g.setDrawingStyle(Graphics.DRAWSTYLE_FOCUS, oldDrawStyleFocus); } }
protected void paint(Graphics g) { int index = g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS) ? FOCUS : NORMAL; g.drawBitmap( 0, 0, _bitmaps[index].getWidth(), _bitmaps[index].getHeight(), _bitmaps[index], 0, 0); }