setMnemonic(int mnemonic)
Sets the keyboard mnemonic on the current model.
Sets the keyboard mnemonic on the current model.
解决方案 »
- synchronized 对数据库操作的问题。。。
- 如何利用JTABLE显示数据 求具体代码?
- 将数据库中的信息作出java GUI图形界面!
- 我想要一本JAVA基础的书。电子版。
- 把变量声明为static有什么用处来着?
- JAVA中如何得到 smt.executeQuery引发的所有SQLException异常列表,或者如何得到这些异常(注意不是一个,是这个类型的所有)
- 关于输入的问题
- 我不知选什么样的java开发工具 最好
- java中有没有这样的函数就是判断一个字符串里面是不是含有另外一个字符串!例如 abcdef 里面查找是不是含有de谢谢了~初学者
- 为什么没人回答我?
- java能写后台驻留程序么?
- 怎么使用jdbc往db2中写入BLOB?
很不方便
给你个设置单键快捷键的实例,自个调用一下就明白了
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;
import java.awt.event.*;
/**
* 作者:alphazhao
* 日期:2002-5-29
* 描述:确定修改备注时,弹出此确定窗口
* 其它:相关注释说明同ShowSelectByName.java
* */public class ShowUpdateMsg extends JDialog {
private TitledBorder titledBorder1;
private String strMsg;
private Font font14 = new Font("Dialog", 0, 14);
private JPanel jPanel1 = new JPanel();
private XYLayout xYLayout1 = new XYLayout();
private JLabel jLabel1 = new JLabel();
private JButton jButton1 = new JButton();
private JButton jButton2 = new JButton();
public ShowUpdateMsg(Dialog owner, boolean modal) {
super(owner,modal);
try {
this.setTitle("系统提示");
this.setResizable(false);
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jPanel1.setLayout(xYLayout1);
jLabel1.setFont(font14);
jLabel1.setText("是否确定要修改记录?"); jButton1.setFont(font14);
jButton1.setText("确 定"); jButton2.setFont(font14);
jButton2.setText("取 消");
this.setSize(350,130); this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jLabel1, new XYConstraints(94, 22, 221, 35));
jPanel1.add(jButton1, new XYConstraints(91, 65, 75, 25));
jPanel1.add(jButton2, new XYConstraints(180, 65, 75, 25)); SymListener symListener = new SymListener();
jButton1.addActionListener(symListener);
jButton2.addActionListener(symListener);
//设置快捷键
jButton1.registerKeyboardAction(symListener,
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
//确定按钮为回车键"ENTER"
jButton2.registerKeyboardAction(symListener,
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
//取消按钮为退出键"Escape"
} void jButton1_actionPerformed(ActionEvent e) {
this.dispose();
}
void jButton2_actionPerformed(ActionEvent e) {
this.dispose();
} ///设置快捷键
class SymListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
Object obj = e.getSource();
if (obj == jButton1) {
jButton1_actionPerformed(e);
}
else if (obj == jButton2) {
jButton2_actionPerformed(e);
}
}
}
}
//end