< prev index next >

src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java

Print this page




 182                         g.setColor(selectionBackground); // Uses protected field.
 183                         g.fillRect(0, 0, menuWidth, menuHeight);
 184                     } else {
 185                         // Draw a raised bevel border
 186                         g.setColor(highlight);
 187                         g.drawLine(0,0, menuWidth - 1,0);
 188                         g.drawLine(0,0, 0,menuHeight - 2);
 189 
 190                         g.setColor(shadow);
 191                         g.drawLine(menuWidth - 1,0, menuWidth - 1,menuHeight - 2);
 192                         g.drawLine(0,menuHeight - 2, menuWidth - 1,menuHeight - 2);
 193                     }
 194                 }
 195             }
 196         }
 197         g.setColor(oldColor);
 198     }
 199 
 200     /**
 201      * Method which renders the text of the current menu item.
 202      * <p>
 203      * @param g Graphics context
 204      * @param menuItem Current menu item to render
 205      * @param textRect Bounding rectangle to render the text.
 206      * @param text String to render
 207      * @since 1.4
 208      */
 209     protected void paintText(Graphics g, JMenuItem menuItem,
 210                              Rectangle textRect, String text) {
 211         if (WindowsMenuItemUI.isVistaPainting()) {
 212             WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
 213             return;
 214         }
 215         JMenu menu = (JMenu)menuItem;
 216         ButtonModel model = menuItem.getModel();
 217         Color oldColor = g.getColor();
 218 
 219         // Only paint rollover if no other menu on menubar is selected
 220         boolean paintRollover = model.isRollover();
 221         if (paintRollover && menu.isTopLevelMenu()) {
 222             MenuElement[] menus = ((JMenuBar)menu.getParent()).getSubElements();




 182                         g.setColor(selectionBackground); // Uses protected field.
 183                         g.fillRect(0, 0, menuWidth, menuHeight);
 184                     } else {
 185                         // Draw a raised bevel border
 186                         g.setColor(highlight);
 187                         g.drawLine(0,0, menuWidth - 1,0);
 188                         g.drawLine(0,0, 0,menuHeight - 2);
 189 
 190                         g.setColor(shadow);
 191                         g.drawLine(menuWidth - 1,0, menuWidth - 1,menuHeight - 2);
 192                         g.drawLine(0,menuHeight - 2, menuWidth - 1,menuHeight - 2);
 193                     }
 194                 }
 195             }
 196         }
 197         g.setColor(oldColor);
 198     }
 199 
 200     /**
 201      * Method which renders the text of the current menu item.
 202      *
 203      * @param g Graphics context
 204      * @param menuItem Current menu item to render
 205      * @param textRect Bounding rectangle to render the text.
 206      * @param text String to render
 207      * @since 1.4
 208      */
 209     protected void paintText(Graphics g, JMenuItem menuItem,
 210                              Rectangle textRect, String text) {
 211         if (WindowsMenuItemUI.isVistaPainting()) {
 212             WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
 213             return;
 214         }
 215         JMenu menu = (JMenu)menuItem;
 216         ButtonModel model = menuItem.getModel();
 217         Color oldColor = g.getColor();
 218 
 219         // Only paint rollover if no other menu on menubar is selected
 220         boolean paintRollover = model.isRollover();
 221         if (paintRollover && menu.isTopLevelMenu()) {
 222             MenuElement[] menus = ((JMenuBar)menu.getParent()).getSubElements();


< prev index next >