Keine Cache-Version

Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code LNG204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.
javax.swing

Class JMenuBar

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible, MenuElement
    Direct Known Subclasses:
    BasicInternalFrameTitlePane.SystemMenuBar

    public class JMenuBar
    extends JComponent
    implements Accessible, MenuElement
    An implementation of a menu bar. You add JMenu objects to the menu bar to construct a menu. When the user selects a JMenu object, its associated JPopupMenu is displayed, allowing the user to select one of the JMenuItems on it.

    For information and examples of using menu bars see How to Use Menus, a section in The Java Tutorial.

    Warning: Swing is not thread safe. For more information see Swing's Threading Policy.

    Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

    See Also:
    JMenu, JPopupMenu, JMenuItem
    • Constructor Detail

      • JMenuBar

        public JMenuBar()
        Creates a new menu bar.
    • Method Detail

      • setSelectionModel

        public void setSelectionModel(SingleSelectionModel model)
        Sets the model object to handle single selections.
        Parameters:
        model - the SingleSelectionModel to use
        See Also:
        SingleSelectionModel
      • add

        public JMenu add(JMenu c)
        Appends the specified menu to the end of the menu bar.
        Parameters:
        c - the JMenu component to add
        Returns:
        the menu component
      • getMenu

        public JMenu getMenu(int index)
        Returns the menu at the specified position in the menu bar.
        Parameters:
        index - an integer giving the position in the menu bar, where 0 is the first position
        Returns:
        the JMenu at that position, or null if if there is no JMenu at that position (ie. if it is a JMenuItem)
      • getMenuCount

        public int getMenuCount()
        Returns the number of items in the menu bar.
        Returns:
        the number of items in the menu bar
      • setHelpMenu

        public void setHelpMenu(JMenu menu)
        Sets the help menu that appears when the user selects the "help" option in the menu bar. This method is not yet implemented and will throw an exception.
        Parameters:
        menu - the JMenu that delivers help to the user
      • getHelpMenu

        public JMenu getHelpMenu()
        Gets the help menu for the menu bar. This method is not yet implemented and will throw an exception.
        Returns:
        the JMenu that delivers help to the user
      • getComponentAtIndex

        @Deprecated
        public Component getComponentAtIndex(int i)
        Deprecated. replaced by getComponent(int i)
        Returns the component at the specified index.
        Parameters:
        i - an integer specifying the position, where 0 is first
        Returns:
        the Component at the position, or null for an invalid index
      • getComponentIndex

        public int getComponentIndex(Component c)
        Returns the index of the specified component.
        Parameters:
        c - the Component to find
        Returns:
        an integer giving the component's position, where 0 is first; or -1 if it can't be found
      • setSelected

        public void setSelected(Component sel)
        Sets the currently selected component, producing a a change to the selection model.
        Parameters:
        sel - the Component to select
      • isSelected

        public boolean isSelected()
        Returns true if the menu bar currently has a component selected.
        Returns:
        true if a selection has been made, else false
      • isBorderPainted

        public boolean isBorderPainted()
        Returns true if the menu bars border should be painted.
        Returns:
        true if the border should be painted, else false
      • setBorderPainted

        public void setBorderPainted(boolean b)
        Sets whether the border should be painted.
        Parameters:
        b - if true and border property is not null, the border is painted.
        See Also:
        isBorderPainted()
      • setMargin

        public void setMargin(Insets m)
        Sets the margin between the menubar's border and its menus. Setting to null will cause the menubar to use the default margins.
        Parameters:
        m - an Insets object containing the margin values
        See Also:
        Insets
      • getMargin

        public Insets getMargin()
        Returns the margin between the menubar's border and its menus. If there is no previous margin, it will create a default margin with zero size.
        Returns:
        an Insets object containing the margin values
        See Also:
        Insets
      • getSubElements

        public MenuElement[] getSubElements()
        Implemented to be a MenuElement -- returns the menus in this menu bar. This is the reason for implementing the MenuElement interface -- so that the menu bar can be treated the same as other menu elements.
        Specified by:
        getSubElements in interface MenuElement
        Returns:
        an array of menu items in the menu bar.
      • paramString

        protected String paramString()
        Returns a string representation of this JMenuBar. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
        Overrides:
        paramString in class JComponent
        Returns:
        a string representation of this JMenuBar
      • getAccessibleContext

        public AccessibleContext getAccessibleContext()
        Gets the AccessibleContext associated with this JMenuBar. For JMenuBars, the AccessibleContext takes the form of an AccessibleJMenuBar. A new AccessibleJMenuBar instance is created if necessary.
        Specified by:
        getAccessibleContext in interface Accessible
        Overrides:
        getAccessibleContext in class JComponent
        Returns:
        an AccessibleJMenuBar that serves as the AccessibleContext of this JMenuBar
      • processKeyBinding

        protected boolean processKeyBinding(KeyStroke ks,
                                KeyEvent e,
                                int condition,
                                boolean pressed)
        Subclassed to check all the child menus.
        Overrides:
        processKeyBinding in class JComponent
        Parameters:
        ks - the KeyStroke queried
        e - the KeyEvent
        condition - one of the following values:
        • JComponent.WHEN_FOCUSED
        • JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
        • JComponent.WHEN_IN_FOCUSED_WINDOW
        pressed - true if the key is pressed
        Returns:
        true if there was a binding to an action, and the action was enabled
        Since:
        1.3

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/swing/jmenubar.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut