}
protected void paintTopLevelMenuBackground(Graphics g, JMenu menu) {
ButtonModel model = menu.getModel();
Color oldColor = g.getColor();
int menuWidth = menu.getWidth();
int menuHeight = menu.getHeight();
if (model.isArmed() || model.isSelected()) {
// Fill-in with color.
g.setColor(UIManager.getColor("OfficeXPLnF.ChosenMenuColor"));
g.fillRect(0,0, menuWidth,menuHeight);
// Draw the "border."
JPopupMenu popupMenu = menu.getPopupMenu();
JMenuBar menuBar = (JMenuBar)menu.getParent();
Point menuLocation = menu.getLocation();
Point popupMenuLocation = SwingUtilities.convertPoint(popupMenu,
popupMenu.getLocation(), menuBar);
//int newX = menuLocation.x - popupMenuLocation.x + 1;
g.setColor(UIManager.getDefaults().getColor("OfficeLnF.MenuBorderColor"));
// If the popup menu is below the menu bar or the popup isn't visible
// (happens if the user presses "Alt" to activate the menus).
if (menuLocation.y<popupMenuLocation.y || !menu.isPopupMenuVisible()) {
g.drawLine(0,2, 0,menuHeight-1);
g.drawLine(0,2, menuWidth-5,2);
g.drawLine(menuWidth-5,2, menuWidth-5,menuHeight-1);
/*
// Shadow - NOT ACCURATE!!
g.setColor(new Color(225,225,225));
g.fillRect(menuWidth-4,6, 4,menuHeight);
g.setColor(new Color(210,210,210));
g.fillRect(menuWidth-4,8, 3,menuHeight);
g.setColor(new Color(180,180,180));
g.drawLine(menuWidth-4,10, menuWidth-4,menuHeight);
g.setColor(new Color(195,195,195));
g.drawLine(menuWidth-3,10, menuWidth-3,menuHeight);
*/
}
// If the popup menu is above the menu bar.
else {
g.drawLine(0,0, 0,menuHeight-2);
g.drawLine(0,menuHeight-2, menuWidth-5,menuHeight-2);
g.drawLine(menuWidth-5,0, menuWidth-5,menuHeight-2);
// Shadow ... ???
}
}
else {
// Needed by both items below.
g.setColor(menu.getBackground());
g.fillRect(0,0, menuWidth, menuHeight);
if (isMouseOver() && model.isEnabled()) {
g.setColor(UIManager.getColor("OfficeLnF.HighlightBorderColor"));
g.drawRect(0,2, menuWidth-5,menuHeight-3);
g.setColor(UIManager.getColor("OfficeLnF.HighlightColor"));
g.fillRect(1,3, menuWidth-6,menuHeight-4);
}