Class TerraMenuSkin

    • Constructor Detail

      • TerraMenuSkin

        public TerraMenuSkin()
    • Method Detail

      • install

        public void install​(Component component)
        Description copied from class: ComponentSkin
        Must be implemented in every subclass in order to do component-specific operations at instantiation time, but every subclass must call this superclass method to setup the necessary listeners, etc.
        Specified by:
        install in interface Skin
        Overrides:
        install in class ContainerSkin
        Parameters:
        component - The component to which the skin is being attached.
      • isFocusable

        public boolean isFocusable()
        Description copied from class: ComponentSkin
        By default, skins are focusable.
        Specified by:
        isFocusable in interface Skin
        Overrides:
        isFocusable in class ContainerSkin
        Returns:
        false; by default, containers are not focusable.
      • getPreferredWidth

        public int getPreferredWidth​(int height)
        Description copied from interface: ConstrainedVisual
        Returns the visual's preferred width given the provided height constraint.
        Specified by:
        getPreferredWidth in interface ConstrainedVisual
        Overrides:
        getPreferredWidth in class ContainerSkin
        Parameters:
        height - The height by which to constrain the preferred width, or -1 for no constraint.
        Returns:
        The preferred width given the height constraint.
      • getPreferredHeight

        public int getPreferredHeight​(int width)
        Description copied from interface: ConstrainedVisual
        Returns the visual's preferred height given the provided width constraint.
        Specified by:
        getPreferredHeight in interface ConstrainedVisual
        Overrides:
        getPreferredHeight in class ContainerSkin
        Parameters:
        width - The width by which to constrain the preferred height, or -1 for no constraint.
        Returns:
        The preferred height given the width constraint.
      • layout

        public void layout()
        Description copied from interface: Skin
        If the component on which the skin is installed is a container, lays out the container's children.
        Specified by:
        layout in interface Skin
      • paint

        public void paint​(java.awt.Graphics2D graphics)
        Description copied from interface: Visual
        Paints the visual.
        Specified by:
        paint in interface Visual
        Overrides:
        paint in class ContainerSkin
        Parameters:
        graphics - The graphics context in which to paint the visual.
      • getFont

        public java.awt.Font getFont()
      • setFont

        public void setFont​(java.awt.Font font)
      • setFont

        public final void setFont​(java.lang.String font)
      • setFont

        public final void setFont​(Dictionary<java.lang.String,​?> font)
      • getColor

        public java.awt.Color getColor()
      • setColor

        public void setColor​(java.awt.Color color)
      • setColor

        public final void setColor​(java.lang.String color)
      • getDisabledColor

        public java.awt.Color getDisabledColor()
      • setDisabledColor

        public void setDisabledColor​(java.awt.Color disabledColor)
      • setDisabledColor

        public final void setDisabledColor​(java.lang.String disabledColor)
      • getActiveColor

        public java.awt.Color getActiveColor()
      • setActiveColor

        public void setActiveColor​(java.awt.Color activeColor)
      • setActiveColor

        public final void setActiveColor​(java.lang.String activeColor)
      • getActiveBackgroundColor

        public java.awt.Color getActiveBackgroundColor()
      • setActiveBackgroundColor

        public void setActiveBackgroundColor​(java.awt.Color activeBackgroundColor)
      • setActiveBackgroundColor

        public final void setActiveBackgroundColor​(java.lang.String activeBackgroundColor)
      • getMarginColor

        public java.awt.Color getMarginColor()
      • setMarginColor

        public void setMarginColor​(java.awt.Color marginColor)
      • getMargin

        public int getMargin()
      • setMargin

        public void setMargin​(int margin)
      • getSeparatorColor

        public java.awt.Color getSeparatorColor()
      • setSeparatorColor

        public void setSeparatorColor​(java.awt.Color separatorColor)
      • getSectionSpacing

        public int getSectionSpacing()
      • setSectionSpacing

        public void setSectionSpacing​(int sectionSpacing)
      • getShowKeyboardShortcuts

        public boolean getShowKeyboardShortcuts()
      • setShowKeyboardShortcuts

        public void setShowKeyboardShortcuts​(boolean showKeyboardShortcuts)
      • keyPressed

        public boolean keyPressed​(Component component,
                                  int keyCode,
                                  Keyboard.KeyLocation keyLocation)
        UP Select the previous enabled menu item.
        DOWN Select the next enabled menu item.
        LEFT Close the current sub-menu.
        RIGHT Open the sub-menu of the current menu item.
        ENTER 'presses' the active menu item if it does not have a sub-menu.
        Specified by:
        keyPressed in interface ComponentKeyListener
        Overrides:
        keyPressed in class ComponentSkin
        Parameters:
        component - Component that has the focus.
        keyCode - The key code for the key that was pressed.
        keyLocation - Location value for the key (left or right for shift keys, etc.).
        Returns:
        true to consume the event; false to allow it to propagate.
      • keyReleased

        public boolean keyReleased​(Component component,
                                   int keyCode,
                                   Keyboard.KeyLocation keyLocation)
        SPACE 'presses' the active menu item if it does not have a sub-menu.
        Specified by:
        keyReleased in interface ComponentKeyListener
        Overrides:
        keyReleased in class ComponentSkin
        Parameters:
        component - Component that has the focus, that is receiving this key event.
        keyCode - Code for the key that was released.
        keyLocation - Location of the key.
        Returns:
        true to consume the event; false to allow it to propagate.
      • keyTyped

        public boolean keyTyped​(Component component,
                                char character)
        Select the next enabled menu item where the first character of the rendered text matches the typed key (case insensitive).
        Specified by:
        keyTyped in interface ComponentKeyListener
        Overrides:
        keyTyped in class ComponentSkin
        Parameters:
        component - Component that has the focus, that is receiving this key.
        character - The decoded character that was typed.
        Returns:
        true to consume the event; false to allow it to propagate.
      • sectionInserted

        public void sectionInserted​(Menu menu,
                                    int index)
        Description copied from interface: MenuListener
        Called when a menu section has been inserted.
        Specified by:
        sectionInserted in interface MenuListener
        Parameters:
        menu - The source of the event.
        index - Where the menu section was inserted.
      • sectionsRemoved

        public void sectionsRemoved​(Menu menu,
                                    int index,
                                    Sequence<Menu.Section> removed)
        Description copied from interface: MenuListener
        Called when menu sections have been removed.
        Specified by:
        sectionsRemoved in interface MenuListener
        Parameters:
        menu - The menu that changed.
        index - The starting index of the removal.
        removed - The actual menu sections that were removed from the menu.
      • itemInserted

        public void itemInserted​(Menu.Section section,
                                 int index)
        Description copied from interface: Menu.SectionListener
        Called when a menu item has been inserted.
        Specified by:
        itemInserted in interface Menu.SectionListener
        Parameters:
        section - The section that is changing.
        index - The index where the item was inserted.
      • itemsRemoved

        public void itemsRemoved​(Menu.Section section,
                                 int index,
                                 Sequence<Menu.Item> removed)
        Description copied from interface: Menu.SectionListener
        Called when menu items have been removed.
        Specified by:
        itemsRemoved in interface Menu.SectionListener
        Parameters:
        section - The section that has changed.
        index - The starting index of the removed items.
        removed - The sequence of the items that were removed.
      • nameChanged

        public void nameChanged​(Menu.Section section,
                                java.lang.String previousName)
        Description copied from interface: Menu.SectionListener
        Called when a section's name has changed.
        Specified by:
        nameChanged in interface Menu.SectionListener
        Parameters:
        section - The section that changed.
        previousName - The previous name for this section.
      • activeItemChanged

        public void activeItemChanged​(Menu menu,
                                      Menu.Item previousActiveItem)
        Description copied from interface: MenuListener
        Called when a menu's active item has changed.
        Specified by:
        activeItemChanged in interface MenuListener
        Parameters:
        menu - The menu that changed.
        previousActiveItem - What the previously active menu item was.