Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.ButtonUI
javax.swing.plaf.MenuItemUI
javax.swing.plaf.basic.BasicMenuItemUI
public class BasicMenuItemUI
extends MenuItemUI
Nested Class Summary | |
protected class |
|
Field Summary | |
protected Font |
|
protected Color |
|
protected Color |
|
protected Icon |
|
protected Icon |
|
protected int |
|
protected Color |
|
protected MenuDragMouseListener |
|
protected JMenuItem |
|
protected MenuKeyListener |
|
protected MouseInputListener |
|
protected boolean |
|
protected Color |
|
protected Color |
|
Constructor Summary | |
|
Method Summary | |
protected MenuDragMouseListener |
|
protected MenuKeyListener |
|
protected MouseInputListener |
|
static ComponentUI |
|
protected void |
|
Dimension |
|
Dimension |
|
MenuElement[] |
|
protected Dimension |
|
Dimension |
|
protected String |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
void |
|
protected void |
|
protected void |
|
protected void | |
protected void |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
void |
|
Methods inherited from class javax.swing.plaf.ComponentUI | |
contains , createUI , getAccessibleChild , getAccessibleChildrenCount , getMaximumSize , getMinimumSize , getPreferredSize , installUI , paint , uninstallUI , update |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected Font acceleratorFont
Font to be used when displaying menu item's accelerator.
protected Color acceleratorForeground
Color to be used when displaying menu item's accelerator.
protected Color acceleratorSelectionForeground
Color to be used when displaying menu item's accelerator when menu item is selected.
protected Icon arrowIcon
Icon that is displayed after the text to indicated that this menu contains submenu.
protected Icon checkIcon
Icon that is displayed before the text. This icon is only used in JCheckBoxMenuItem or JRadioBoxMenuItem.
protected MenuDragMouseListener menuDragMouseListener
The menu Drag mouse listener listening to the menu item.
protected MenuKeyListener menuKeyListener
Menu Key listener listening to the menu item.
protected MouseInputListener mouseInputListener
mouse input listener listening to menu item.
protected Color selectionBackground
Color of text that is used when menu item is selected
protected Color selectionForeground
Color of the text that is used when menu item is selected.
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
Create MenuDragMouseListener to listen for mouse dragged events.
- Parameters:
c
- menu item to listen to
- Returns:
- The MenuDragMouseListener
protected MenuKeyListener createMenuKeyListener(JComponent c)
Creates MenuKeyListener to listen to key events occuring when menu item is visible on the screen.
- Parameters:
c
- menu item to listen to
- Returns:
- The MenuKeyListener
protected MouseInputListener createMouseInputListener(JComponent c)
Handles mouse input events occuring for this menu item
- Parameters:
c
- menu item to listen to
- Returns:
- The MouseInputListener
public static ComponentUI createUI(JComponent c)
Factory method to create a BasicMenuItemUI for the givenJComponent
, which should be aJMenuItem
.
- Overrides:
- createUI in interface ComponentUI
- Parameters:
c
- TheJComponent
a UI is being created for.
- Returns:
- A BasicMenuItemUI for the
JComponent
.
protected void doClick(MenuSelectionManager msm)
Programatically clicks menu item.
- Parameters:
msm
- MenuSelectionManager for the menu hierarchy
public Dimension getMaximumSize(JComponent c)
Returns maximum size for the specified menu item
- Overrides:
- getMaximumSize in interface ComponentUI
- Parameters:
c
- component for which to get maximum size
- Returns:
- Maximum size for the specified menu item.
public Dimension getMinimumSize(JComponent c)
Returns minimum size for the specified menu item
- Overrides:
- getMinimumSize in interface ComponentUI
- Parameters:
c
- component for which to get minimum size
- Returns:
- Minimum size for the specified menu item.
public MenuElement[] getPath()
Returns path to this menu item.
- Returns:
- $MenuElement[]$ Returns array of menu elements that constitute a path to this menu item.
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap)
Returns preferred size for the given menu item.
- Parameters:
c
- menu item for which to get preferred sizecheckIcon
- check icon displayed in the given menu itemarrowIcon
- arrow icon displayed in the given menu itemdefaultTextIconGap
- space between icon and text in the given menuItem
- Returns:
- $Dimension$ preferred size for the given menu item
public Dimension getPreferredSize(JComponent c)
Returns preferred size of the given component
- Overrides:
- getPreferredSize in interface ComponentUI
- Parameters:
c
- component for which to return preferred size
- Returns:
- $Dimension$ preferred size for the given component
protected String getPropertyPrefix()
Returns the prefix for entries in theUIDefaults
table.
- Returns:
- "MenuItem"
protected void installComponents(JMenuItem menuItem)
This method installs the components for thisJMenuItem
.
- Parameters:
menuItem
- TheJMenuItem
to install components for.
protected void installDefaults()
This method installs the defaults that are defined in the Basic look and feel for thisJMenuItem
.
protected void installKeyboardActions()
This method installs the keyboard actions for thisJMenuItem
.
protected void installListeners()
This method installs the listeners for theJMenuItem
.
public void installUI(JComponent c)
Installs and initializes all fields for this UI delegate. Any properties of the UI that need to be initialized and/or set to defaults will be done now. It will also install any listeners necessary.
- Overrides:
- installUI in interface ComponentUI
- Parameters:
c
- TheJComponent
that is having this UI installed.
public void paint(Graphics g, JComponent c)
Paints given menu item using specified graphics context
- Overrides:
- paint in interface ComponentUI
- Parameters:
g
- The graphics context used to paint this menu itemc
- Menu Item to paint
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
Paints background of the menu item
- Parameters:
g
- The graphics context used to paint this menu itemmenuItem
- menu item to paintbgColor
- Background color to use when painting menu item
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap)
Paints specified menu item
- Parameters:
g
- The graphics context used to paint this menu itemc
- menu item to paintcheckIcon
- check icon to use when painting menu itemarrowIcon
- arrow icon to use when painting menu itembackground
- Background color of the menu itemforeground
- Foreground color of the menu itemdefaultTextIconGap
- space to use between icon and text when painting menu item
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text)
Paints label for the given menu item
- Parameters:
g
- The graphics context used to paint this menu itemmenuItem
- menu item for which to draw its labeltextRect
- rectangle specifiying position of the text relative to the given menu itemtext
- label of the menu item
protected void uninstallComponents(JMenuItem menuItem)
This method uninstalls the components for thisJMenuItem
.
- Parameters:
menuItem
- TheJMenuItem
to uninstall components for.
protected void uninstallDefaults()
This method uninstalls the defaults and sets any objects created during install to null
protected void uninstallListeners()
Unregisters all the listeners that this UI delegate was using.
public void uninstallUI(JComponent c)
Performs the opposite of installUI. Any properties or resources that need to be cleaned up will be done now. It will also uninstall any listeners it has. In addition, any properties of this UI will be nulled.
- Overrides:
- uninstallUI in interface ComponentUI
- Parameters:
c
- TheJComponent
that is having this UI uninstalled.
public void update(Graphics g, JComponent c)
This method calls paint.
- Overrides:
- update in interface ComponentUI
- Parameters:
g
- The graphics context used to paint this menu itemc
- The menu item to paint