Here you can find the source of pintaBarraMenu(Graphics g, JMenuItem menuItem, Color bgColor)
static void pintaBarraMenu(Graphics g, JMenuItem menuItem, Color bgColor)
//package com.java2s; /*/*from w ww . j a v a 2 s. c o m*/ * (C) Copyright 2005 Nilo J. Gonzalez * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser Gereral Public Licence as published by the Free * Software Foundation; either version 2 of the Licence, or (at your opinion) any * later version. * * This library is distributed in the hope that it will be usefull, but WITHOUT ANY * WARRANTY; without even the implied warranty of merchantability or fitness for a * particular purpose. See the GNU Lesser General Public Licence for more details. * * You should have received a copy of the GNU Lesser General Public Licence along * with this library; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, Ma 02111-1307 USA. * * http://www.gnu.org/licenses/lgpl.html (English) * http://gugs.sindominio.net/gnu-gpl/lgpl-es.html (Espa?ol) * * * Original author: Nilo J. Gonzalez */ import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class Main { /** * Esta funcion se usa para pintar la barra de seleccion de los menus. Esta aqui * para no repetirla en todas partes... */ static void pintaBarraMenu(Graphics g, JMenuItem menuItem, Color bgColor) { ButtonModel model = menuItem.getModel(); Color oldColor = g.getColor(); int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); if (menuItem.isOpaque()) { g.setColor(menuItem.getBackground()); g.fillRect(0, 0, menuWidth, menuHeight); } if ((menuItem instanceof JMenu && !(((JMenu) menuItem).isTopLevelMenu()) && model .isSelected()) || model.isArmed()) { RoundRectangle2D.Float boton = new RoundRectangle2D.Float(); boton.x = 1; boton.y = 0; boton.width = menuWidth - 3; boton.height = menuHeight - 1; boton.arcwidth = 8; boton.archeight = 8; GradientPaint grad = new GradientPaint(1, 1, getBrilloMenu(), 0, menuHeight, getSombraMenu()); Graphics2D g2D = (Graphics2D) g; g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(bgColor); g2D.fill(boton); g.setColor(bgColor.darker()); g2D.draw(boton); g2D.setPaint(grad); g2D.fill(boton); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT); } g.setColor(oldColor); } static Color getBrilloMenu() { return new Color(255, 255, 255, 64); } static Color getSombraMenu() { return new Color(20, 20, 20, 50); } }