- 浏览: 224713 次
- 性别:
- 来自: 淄博
文章分类
- 全部博客 (666)
- java (6)
- android (9)
- 架构 (0)
- android游戏 (13)
- android系统 (14)
- c++ (14)
- 数据库 (10)
- javascript (2)
- 版本控制 (1)
- webservice (1)
- linux (5)
- uml (1)
- android多媒体部分 (16)
- java中的JNI (6)
- HTML5 (5)
- CSS3 (1)
- swing (13)
- 线程并发 (9)
- 分布式 (5)
- 云计算 (1)
- 通信协议 (4)
- xml (4)
- c# (1)
- lucene (0)
- ibatis (0)
- hibernate (3)
- struts1 (3)
- struts2 (4)
- jsf (0)
- spring (5)
- spring for android (0)
- 感悟 (2)
- jpa (1)
- android gis (1)
- jbpm (0)
- java设计模式 (8)
- java web (4)
- EXT js (0)
- node JS (2)
- python (3)
- c (17)
- weblogic (0)
- opencv (1)
最新评论
/**
* 菜单快捷键
*
* @time 12:40:40 PM
* @author retacn yue
* @Email zhenhuayue@sina.com
*/
public class Test_ShortcutTest extends Frame {
private static final long serialVersionUID = 1L;
double a, d, n, sum;
// 参数用于指定列数
TextField textField1 = new TextField(5),//
textField2 = new TextField(5),//
textField3 = new TextField(5),//
textField4 = new TextField(10);//
Label label1 = new Label("******计算等差/等比级数********"),//
label2 = new Label("输入初始值:"),//
label3 = new Label("输入公差/公比值:"),//
label4 = new Label("输出第几项"),//
label5 = new Label("输出总和:");//
/**
* 菜单快捷键
*
* 第二个参数是否需要同时按下shift键
*/
MenuShortcut menuShortcut1 = new MenuShortcut(KeyEvent.VK_A, true),//
menuShortcut2 = new MenuShortcut(KeyEvent.VK_S, false);
// 菜单栏
MenuBar bar = new MenuBar();
Menu menu = new Menu("级数");
MenuItem sz1 = new MenuItem("等差级数", menuShortcut1),//
sz2 = new MenuItem("等比级数", menuShortcut2);//
/**
* 构造器
*/
private Test_ShortcutTest() {
super("菜单快捷键测试");
setLayout(new FlowLayout());
setBackground(Color.orange);
menu.add(sz1);
menu.add(sz2);
bar.add(menu);
setMenuBar(bar);
add(label1);
add(label2);
add(textField1);
add(label3);
add(textField2);
add(label4);
add(textField3);
add(label5);
add(textField4);
setSize(200, 180);
setVisible(true);
addWindowListener(new koWindowListener());
sz1.addActionListener(new koActionListener());
sz2.addActionListener(new koActionListener());
}
/**
* 关闭窗体
*
* @time 1:22:40 PM
* @author retacn yue
* @Email zhenhuayue@sina.com
*/
class koWindowListener extends WindowAdapter {
@Override
public void windowClosing(WindowEvent e) {
e.getWindow().dispose();
System.exit(0);
}
}
/**
* 菜单单击监听
*
*/
class koActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
a = new Double(textField1.getText()).doubleValue();
d = new Double(textField2.getText()).doubleValue();
n = new Double(textField3.getText()).doubleValue();
if (e.getSource() == sz1) {
textField4.setBackground(Color.yellow);
// 计算等差级数的总和
// 公式为:s=(a1+an)n/2
sum = (2 * a + (n - 1) * d) * n / 2;
} else if (e.getSource() == sz2) {
textField4.setBackground(Color.green);
/**
* 计算等比级数的总和
*
* 设比例因子为q 项数为n 首项为a1 和s=a1*(1-q^n)/(1-q)
*/
sum = a * (1 - Math.pow(d, n)) / (1 - d);
}
textField4.setText(String.valueOf(sum));
}
}
public static void main(String[] args) {
new Test_ShortcutTest();
}
}
发表评论
-
swing 学习笔记一(画板Panel )
2012-09-04 11:18 735/** * 画板 * * @time 3:38:10 P ... -
swing学习笔记二(画布Canvas)
2012-09-04 11:19 650/** * 画布 * @time 11:23:53 AM ... -
swing学习笔记四(单选按钮JRadioButton )
2012-09-06 22:44 300/** * 单选按钮 * @time 下午10:48:14 ... -
swing学习笔记五(进度条ProgressMonitor )
2012-09-06 22:44 686/** * 进度条 * * @time 3:30:01 ... -
swing学习笔记六(对话框Dialog )
2012-09-06 22:47 678/** * 对话框 * * @time 11:09:20 ... -
swing 学习笔记七(菜单MenuBar )
2012-09-06 22:49 785/** * 菜单 * * @time 10:24:50 ... -
swing 学习笔记八(列表JList )
2012-09-08 16:32 637/** * 列表 * @time 4:53:26 PM ... -
swing 学习笔记九(选项卡 JApplet是japplet的扩展)
2012-09-08 16:33 637/** * 选项卡 JApplet是japplet的扩展 ... -
swing 学习笔记十(边界面局管理BorderLayout)
2012-09-08 16:35 547/** * 边界面局管理 * * @time 2:59: ... -
swing学习笔记十一(卡片布局管理器CardLayout )
2012-09-09 10:54 638/** * 卡片布局管理器 * * @time 9:49 ... -
swing 学习笔记十二(网格布局GridLayout)
2012-09-09 10:59 518/** * 网格布局 * * @time 3:22:44 ... -
swing学习笔记十四(复选框JCheckBox )
2012-09-09 11:00 554/** * 复选框 * * @time 3:54:18 ...
相关推荐
JavaFX+Jfoenix 学习笔记系列的JavaFX+Jfoenix 学习笔记(四)--MenuBar菜单栏的源码
通过xml文件配制Menubar实现动态填充菜单!再过itemClick事件获取下次子菜单
Python_tkinter_9_Menubar_菜单_(GUI_窗口_教学教程tutorial)
menuBar.7z菜单栏
qt5用代码实现界面创建,工具栏toolbar和菜单栏menubar。
FLex MenuBar的小例子,可以实现下拉菜单的效果,可直接拷贝使用
matlab开发-MenuBar。在图形窗口中的任何位置创建菜单栏
VC++的工具栏菜单,带源程序和DEMO 在VC7.0 VC7.1 VC8.0及ARX中调试通过
menubar rebar rightclick
.NET 较新版本中移除了系统样式的MenuBar,进而使用MenuStrip。该实例还原了系统菜单栏,更加美观。 (如无法打开,请在文件名后加上后缀“.zip”)
利用QML写的菜单样式,适合项目中用,定义了MenuItem和MenuBar的样式。实现是在Qt5.12.0中,应该是Qt5.10及以上都可以的。
这个功能MenuBar,允许用户在图中的任何地方创建菜单它用真正的菜单栏替换了 UIpanels 的 UIcontextmenu。 菜单栏(figure_handle)或菜单栏 鼠标悬停,可以通过以下方式启用窗口调整大小更新menubar('start',...
Private WithEvents MenuBar_MenuItem As MSForms.Label '菜单项 Private WithEvents WorkForm As MSForms.UserForm '工作窗口 Private WithEvents MenuBar As MSForms.Image '菜单栏 Private BackMenu_BackGroud As...
菜单栏通常包含一个或多个菜单,每个菜单包含若干个菜单项(`QAction`)。可以通过`QMenuBar`、`QMenu` 和 `QAction` 类来创建和管理菜单栏及其菜单项。 1. **创建一个菜单栏:** ```cpp QMenuBar *menuBar = ...
本案例是模仿饿了么,实现横向导航栏,可以参考用,也可以直接插入到项目中,接口方面使用的是mockJS模拟接口
Laravel开发-menubar 拉拉维尔的菜单栏建设者
TMenuBar component.
然后您可以使用codebox.menubar访问菜单栏: codebox . menubar . addMenu ( { caption : "My New Menu" , items : [ { caption : "My Command" , command : "mycomand" } , { type : "separator" } , {
用于替换 Visual C++ 使用开发人员 Studio 对象模型中的打开和添加文件到工程菜单项。解决这两个菜单项出错的问题。
一个工具栏菜单的源程序