This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.plaf.basic
class BasicMenuItemUI

java.lang.Object extended by javax.swing.plaf.ComponentUI extended by javax.swing.plaf.ButtonUI extended by javax.swing.plaf.MenuItemUI extended by javax.swing.plaf.basic.BasicMenuItemUI
Direct Known Subclasses:
BasicCheckBoxMenuItemUI, BasicMenuUI, BasicRadioButtonMenuItemUI

public class BasicMenuItemUI
extends MenuItemUI

BasicMenuItem implementation


Nested Class Summary
protected class

          
 
Field Summary
protected Font acceleratorFont
          
protected Color acceleratorForeground
          
protected Color acceleratorSelectionForeground
          
protected Icon arrowIcon
          
protected Icon checkIcon
          
protected int defaultTextIconGap
          
protected Color disabledForeground
          
protected MenuDragMouseListener menuDragMouseListener
          
protected JMenuItem menuItem
          
protected MenuKeyListener menuKeyListener
          
protected MouseInputListener mouseInputListener
          
protected boolean oldBorderPainted
          
protected PropertyChangeListener propertyChangeListener
          PropertyChangeListener returned from createPropertyChangeListener.
protected Color selectionBackground
          
protected Color selectionForeground
          
 
Constructor Summary

          
 
Method Summary
protected MenuDragMouseListener

          
protected MenuKeyListener

          
protected MouseInputListener

          
protected PropertyChangeListener

          Creates a PropertyChangeListener which will be added to the menu item.
static ComponentUI

          
protected void

          Call this method when a menu item is to be activated.
 Dimension

          Returns the specified component's maximum size appropriate for the look and feel.
 Dimension

          Returns the specified component's minimum size appropriate for the look and feel.
 MenuElement[]

          
protected Dimension
getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap)

          
 Dimension

          Returns the specified component's preferred size appropriate for the look and feel.
protected String

          
protected void

          
protected void

          
protected void

          
protected void

          
 void

          Configures the specified component appropriate for the look and feel.
 void

          Paints the specified component appropriate for the look and feel.
protected void
paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)

          Draws the background of the menu item.
protected void
paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap)

          
protected void
paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text)

          Renders the text of the current menu item.
protected void

          
protected void

          
protected void

          
protected void

          
 void

          Reverses configuration which was done on the specified component during installUI.
 void

          We draw the background in paintMenuItem() so override update (which fills the background of opaque components by default) to just call paint().
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, uninstallUI, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

acceleratorFont

protected Font acceleratorFont

acceleratorForeground

protected Color acceleratorForeground

acceleratorSelectionForeground

protected Color acceleratorSelectionForeground

arrowIcon

protected Icon arrowIcon

checkIcon

protected Icon checkIcon

defaultTextIconGap

protected int defaultTextIconGap

disabledForeground

protected Color disabledForeground

menuDragMouseListener

protected MenuDragMouseListener menuDragMouseListener

menuItem

protected JMenuItem menuItem

menuKeyListener

protected MenuKeyListener menuKeyListener

mouseInputListener

protected MouseInputListener mouseInputListener

oldBorderPainted

protected boolean oldBorderPainted

propertyChangeListener

protected PropertyChangeListener propertyChangeListener
PropertyChangeListener returned from createPropertyChangeListener. You should not need to access this field, rather if you want to customize the PropertyChangeListener override createPropertyChangeListener.

selectionBackground

protected Color selectionBackground

selectionForeground

protected Color selectionForeground
Constructor Detail

BasicMenuItemUI

public BasicMenuItemUI()
Method Detail

createMenuDragMouseListener

protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
Parameters:
c

createMenuKeyListener

protected MenuKeyListener createMenuKeyListener(JComponent c)
Parameters:
c

createMouseInputListener

protected MouseInputListener createMouseInputListener(JComponent c)
Parameters:
c

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener(JComponent c)
Creates a PropertyChangeListener which will be added to the menu item. If this method returns null then it will not be added to the menu item.

Parameters:
c
Returns:
an instance of a PropertyChangeListener or null

createUI

public static ComponentUI createUI(JComponent c)
Parameters:
c

doClick

protected void doClick(MenuSelectionManager msm)
Call this method when a menu item is to be activated. This method handles some of the details of menu item activation such as clearing the selected path and messaging the JMenuItem's doClick() method.

Parameters:
msm - A MenuSelectionManager. The visual feedback and internal bookkeeping tasks are delegated to this MenuSelectionManager. If null is passed as this argument, the MenuSelectionManager.defaultManager is used.

getMaximumSize

public Dimension getMaximumSize(JComponent c)
Overrides:
getMaximumSize in class ComponentUI
Parameters:
c

getMinimumSize

public Dimension getMinimumSize(JComponent c)
Overrides:
getMinimumSize in class ComponentUI
Parameters:
c

getPath

public MenuElement[] getPath()

getPreferredMenuItemSize

protected Dimension getPreferredMenuItemSize(JComponent c,
                                             Icon checkIcon,
                                             Icon arrowIcon,
                                             int defaultTextIconGap)
Parameters:
c
checkIcon
arrowIcon
defaultTextIconGap

getPreferredSize

public Dimension getPreferredSize(JComponent c)
Overrides:
getPreferredSize in class ComponentUI
Parameters:
c

getPropertyPrefix

protected String getPropertyPrefix()

installComponents

protected void installComponents(JMenuItem menuItem)
Parameters:
menuItem

installDefaults

protected void installDefaults()

installKeyboardActions

protected void installKeyboardActions()

installListeners

protected void installListeners()

installUI

public void installUI(JComponent c)
Overrides:
installUI in class ComponentUI
Parameters:
c

paint

public void paint(Graphics g,
                  JComponent c)
Overrides:
paint in class ComponentUI
Parameters:
g
c

paintBackground

protected void paintBackground(Graphics g,
                               JMenuItem menuItem,
                               Color bgColor)
Draws the background of the menu item.

Parameters:
g - the paint graphics
menuItem - menu item to be painted
bgColor - selection background color

paintMenuItem

protected void paintMenuItem(Graphics g,
                             JComponent c,
                             Icon checkIcon,
                             Icon arrowIcon,
                             Color background,
                             Color foreground,
                             int defaultTextIconGap)
Parameters:
g
c
checkIcon
arrowIcon
background
foreground
defaultTextIconGap

paintText

protected void paintText(Graphics g,
                         JMenuItem menuItem,
                         Rectangle textRect,
                         String text)
Renders the text of the current menu item.

Parameters:
g - graphics context
menuItem - menu item to render
textRect - bounding rectangle for rendering the text
text - string to render

uninstallComponents

protected void uninstallComponents(JMenuItem menuItem)
Parameters:
menuItem

uninstallDefaults

protected void uninstallDefaults()

uninstallKeyboardActions

protected void uninstallKeyboardActions()

uninstallListeners

protected void uninstallListeners()

uninstallUI

public void uninstallUI(JComponent c)
Overrides:
uninstallUI in class ComponentUI
Parameters:
c

update

public void update(Graphics g,
                   JComponent c)
We draw the background in paintMenuItem() so override update (which fills the background of opaque components by default) to just call paint().

Overrides:
update in class ComponentUI
Parameters:
g
c


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.