【正文】
Mac users is probably worth it. The second way to add a menu bar is much less mon. Recall that the JMenuBar class extendsJComponent. This means it can be positioned by a Swing layout manager like other Swing ponents. For example, we could replace the call 3 to setJMenuBar( ) with the following code: (new BevelBorder())。F can be configured to place menu bars at the top of the screen, where Mac users expect to find them. Setting the system property to true activates thisbehavior. It39。F to determine the location of the menu (typically, it anchors the menu bar to the top of a frame, adjusting the frame39。 // Attach the menu bar to the frame. (menuBar)。F. In practice, trying to do this results in JMenuBar throwing an Error. Menu Bar Placement You can attach menu bars to Swing frames or applets in one of two ways. First, 2 you can use thesetJMenuBar( ) method of JFrame, JDialog, JApplet, or JInternalFrame: JFrame frame = new JFrame(Menu)。sJMenuBar class supersedes the AWTMenuBar class. This class creates a horizontal menu bar ponent with zero or more menus attached to it. JMenuBar uses theDefaultSingleSelectionModel as its data model because the user can raise, or activate , only one of its menus at a given time. Once the mouse pointer leaves that menu, the class removes the menu from the screen (or cancels it, in Swing lingo), and all menus again bee eligible to be raised Figure 144 shows the class hierarchy for the JMenuBar ponent. Figure 144. JMenuBar class diagram You can add JMenu objects to the menu bar with theadd( ) method of theJMenuBar class. JMenuBar then assigns an integer index based on the order in which the menus were added. The menu bar displays the menus from left to right on the bar according to their assigned index. In theory, there is one exception: the help menu. You are supposed to be allowed to mark one menu as the help menu。中文 1972 字 畢業(yè)設(shè)計(論文)文獻翻譯 題 目 學生姓名 學 號 專業(yè)名稱 計算機科學與技術(shù) 年 級 2020 級 指導教師 職 稱