北京邮电大学世纪学院
毕业设计(论文)文献翻译
题 目 基于SWING组件技术的电子词典的
设计与实现
学生姓名 学 号
专业名称 计算机科学与技术 年 级 2013级
指导教师 职 称
所 在 系(院) 计算机科学与技术
20 年 月 日
Menus and Toolbars
Excerpted from Java Swing(2Nd Edition)(OReilly)by Marc Loy,Robert Eckstein etc.
The JMenuBar Class
SwingsJMenuBar class supersedes the AWTMenuBar class. This class creates a horizontal menu bar component 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 become eligible to be raised Figure 14-4 shows the class hierarchy for the JMenuBar component.
Figure 14-4. 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; the location of the help menu is up to the LF. 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, you can use thesetJMenuBar( ) method of JFrame, JDialog, JApplet, or JInternalFrame:
JFrame frame = new JFrame(Menu);
JMenuBar menuBar = new JMenuBar( );
// Attach the menu bar to the frame.
frame.setJMenuBar(menuBar);
The setJMenuBar( ) method is analogous to thesetMenuBar( ) method ofjava.awt.Frame. Like its predecessor, setJMenuBar( ) allows the LF to determine the location of the menu (typically, it anchors the menu ba
您可能关注的文档
- 四川省资阳市2016届高三下学期高考模拟考试物理试题解读.doc
- 世界各地婚俗详解.ppt
- 塑料、纤维和橡胶解读.ppt
- 世界地理—欧洲东部、俄罗斯详解.ppt
- 四个能力建设相关表本册解读.doc
- 四号炉工业水系统(冯志刚)解读.ppt
- 四级翻译练习解读.ppt
- 世界各大即时通讯工具详解.ppt
- 四联移民安置点景观设计任务书解读.doc
- 四六级翻译练习题解读.doc
- GB/T 42818.2-2026认知无障碍 第2部分:报告.pdf
- 中国国家标准 GB/T 47116-2026地下采矿机械 工作面移动式采掘机械 采煤机和犁式系统的安全要求.pdf
- 《GB/T 47116-2026地下采矿机械 工作面移动式采掘机械 采煤机和犁式系统的安全要求》.pdf
- 中国国家标准 GB/T 42818.2-2026认知无障碍 第2部分:报告.pdf
- 《GB/T 42818.2-2026认知无障碍 第2部分:报告》.pdf
- 《GB/T 27664.1-2026无损检测仪器 超声检测设备的性能与检验 第1部分:仪器》.pdf
- 中国国家标准 GB/T 27664.1-2026无损检测仪器 超声检测设备的性能与检验 第1部分:仪器.pdf
- GB/T 27664.1-2026无损检测仪器 超声检测设备的性能与检验 第1部分:仪器.pdf
- GB/T 45305.5-2026声学 建筑构件隔声的实验室测量 第5部分:测试设施和设备的要求.pdf
- 中国国家标准 GB/T 45305.5-2026声学 建筑构件隔声的实验室测量 第5部分:测试设施和设备的要求.pdf
原创力文档

文档评论(0)