|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
还是要自己一点一点写代码,然后编译,改错再编译好那。还有最重要的是.net的编译环境非常好,你甚是不需要了解太多工具,对于简单的系统,你可以之了解一些语法就哦了。
比来看到有人问怎样摹拟钢琴操纵
想了想怎样完成特地看了下键盘事务
能够用两种体例
1、
publicclassKeystrokeTestextendsJApplet{
privateJButtonbutton=newJButton("button");
publicvoidinit(){
ContainercontentPane=getContentPane();
JPanelpanel=newJPanel();
JCheckBoxcheckbox=newJCheckBox("checkbox");
JButtonsouthButton=newJButton("southbutton");
Listenerlistener=newListener();
panel.setBorder(BorderFactory
.createTitledBorder(("Ancestorofbuttonandcheckbox")));
checkbox.registerKeyboardAction(listener,KeyStroke.getKeyStroke(
KeyEvent.VK_F,0,false),JComponent.WHEN_FOCUSED);
panel.registerKeyboardAction(listener,KeyStroke.getKeyStroke(
KeyEvent.VK_A,InputEvent.ALT_MASK,false),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
southButton.registerKeyboardAction(listener,KeyStroke.getKeyStroke(
KeyEvent.VK_W,0,true),JComponent.WHEN_IN_FOCUSED_WINDOW);
panel.add(button);
panel.add(checkbox);
contentPane.add(panel,"Center");
contentPane.add(southButton,"South");
}
}
classListenerimplementsActionListener{
publicvoidactionPerformed(ActionEvente){
Objectsrc=e.getSource();
Stringcname=src.getClass().getName();
if(srcinstanceofJCheckBox){
System.out.print("fkeyPRESSEDwhencheckbox");
System.out.println("hadfocus");
}elseif(srcinstanceofJPanel){
System.out.print("ALT-akeyPRESSEDwhenancestor");
System.out.println("oftitledpanelhadfocus");
}elseif(srcinstanceofJButton){
System.out.print("wkeyRELEASEDwhenany");
System.out.println("componentinwindowhadfocus");
}
System.out.println("Source:"+cname);
System.out.println();
}
}
<p>
Java的桌面程序开发在java程序员里通常叫swing开发,主要用的swing包里的类开发的,也就是通常说的c/s架构开发 |
|