private void internalPaintTabBackground( Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { BufferedImage leftImg = null; BufferedImage middleImg = null; BufferedImage rightImg = null; Graphics2D g2 = (Graphics2D) g; AntialiasingManager.activateAntialiasing(g2); int tabOverlap = 0; if (isSelected) { if (tabPane.isEnabledAt(tabIndex)) { leftImg = DesktopUtilActivator.getImage(SELECTED_TAB_LEFT_BG); middleImg = DesktopUtilActivator.getImage(SELECTED_TAB_MIDDLE_BG); rightImg = DesktopUtilActivator.getImage(SELECTED_TAB_RIGHT_BG); tabOverlap = TAB_OVERLAP; } else { leftImg = DesktopUtilActivator.getImage(TAB_LEFT_BG); middleImg = DesktopUtilActivator.getImage(TAB_MIDDLE_BG); rightImg = DesktopUtilActivator.getImage(TAB_RIGHT_BG); } } else { leftImg = DesktopUtilActivator.getImage(TAB_LEFT_BG); middleImg = DesktopUtilActivator.getImage(TAB_MIDDLE_BG); rightImg = DesktopUtilActivator.getImage(TAB_RIGHT_BG); } // Remove the existing gap between the tabs and the panel, which is due // to the removal of the tabbed pane border. y++; // If the current tab is not the selected tab we paint it 2 more pixels // to the bottom in order to create the disabled look. if (!isSelected) y += 2; g2.drawImage(leftImg, x, y, null); g2.drawImage( middleImg, x + leftImg.getWidth(), y, w - leftImg.getWidth() - rightImg.getWidth() + tabOverlap, leftImg.getHeight(), null); g2.drawImage(rightImg, x + w - rightImg.getWidth() + tabOverlap, y, null); }
/** * Paints this button. * * @param g the <tt>Graphics</tt> object used for painting */ private void internalPaintComponent(Graphics2D g) { AntialiasingManager.activateAntialiasing(g); // Paint a roll over fade out. FadeTracker fadeTracker = FadeTracker.getInstance(); float visibility = this.getModel().isRollover() ? 1.0f : 0.0f; if (fadeTracker.isTracked(this, FadeKind.ROLLOVER)) { visibility = fadeTracker.getFade(this, FadeKind.ROLLOVER); } visibility /= 2; if (visibility != 0.0f) { g.setColor(new Color(borderColor[0], borderColor[1], borderColor[2], visibility)); if (bgImage != null) g.fillRoundRect( (this.getWidth() - bgImage.getWidth(null)) / 2, (this.getHeight() - bgImage.getHeight(null)) / 2, bgImage.getWidth(null) - 1, bgImage.getHeight(null) - 1, 20, 20); else g.fillRoundRect(0, 0, this.getWidth() - 1, this.getHeight() - 1, 20, 20); } if (bgImage != null) { g.drawImage( bgImage, (this.getWidth() - bgImage.getWidth(null)) / 2, (this.getHeight() - bgImage.getHeight(null)) / 2, null); } else { g.setColor(getBackground()); g.fillRoundRect(1, 1, this.getWidth() - 2, this.getHeight() - 2, 20, 20); } }
/** * Paints the UI for the given component through the given graphics object. * * @param g the <tt>Graphics</tt> object used for painting * @param c the component to paint */ public void paint(Graphics g, JComponent c) { AntialiasingManager.activateAntialiasing(g); super.paint(g, c); }