计算机代码翻译工具栏,毕业设计--计算机外文翻译 -菜单和工具栏.doc

毕业设计--计算机外文翻译 -菜单和工具栏

中文1972字

毕业设计(论文)文献翻译

题 目

学生姓名 学 号

专业名称 计算机科学与技术 年 级 2009级

指导教师 职 称 讲 师

所 在 系(院) 计算机科学与技术

2013 年 3 月 1 日

Menus and Toolbars

Excerpted from "Java Swing(2Nd Edition)(O'Reilly)"by Marc Loy,Robert Eckstein etc.

The JMenuBar Class

Swing'sJMenuBar 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 L&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, 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 L&F to determine the location of the menu (typically, it anchors the menu bar to the top of a frame, adjusting t

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值