Java¿ì½Ý¼üÖÆ×÷
Java¿ì½Ý¼üÖÆ×÷
ÓùýVBµÄÖªµÀ°´ÏÂF5ÊÇÔËÐд°Ì壬ÓùýPhotoshopµÄÖªµÀ°´ÏÂTabÊÇÒþ²ØËùÓÐÃæ°å
£¬ÄãµÄJava³ÌÐòÒ²ÏëÓÐÕâ¸ö¹¦ÄÜô£¿ÄÇôϣÍûÕâÆªÎÄÕ¶ÔÄúÓÐËù°ïÖú¡£
×Ӳ˵¥ÀàJMenuItemÓÐÒ»¸ö·½·¨²»ÖªµÀÄã×¢Òâ¹ýûÓÐ:setAccelerator¡£
´ò¿ª°ïÖúÎļþ¶ÔÕâ¸ö·½·¨µÄÃèÊöÊÇ£º ÉèÖÃ×éºÏ¼ü£¬ËüÄÜÖ±½Óµ÷Óò˵¥ÏîµÄ²Ù×÷
ÕìÌýÆ÷¶ø²»±ØÏÔʾ²Ëµ¥µÄ²ã´Î½á¹¹¡£ËùÒÔÓÃÕâ¸ö·½·¨¾ÍÄÜÖÆ×÷ÎÒÃÇËùÒªµÄ¿ì½Ý¼ü
ÁË¡£
°ïÖúÎļþ¸æËßÎÒÃÇ£¬´«¸øsetAccelerator·½·¨ËùÒªµÄÊÇÒ»¸öKeyStroke£¬ÏÂÃæÀ´
˵˵Õâ¸öÀࣺ
KeyStokeÔÚJavax.swing°üÏ£¬ËûµÄ×÷Óý«ÎÒÃÇÒªµÄ¼ü"À¦"ÆðÀ´£¬ÔÙ´«¸øÉÏÃæËù
˵µÄsetAcceleratorÖ®ÀàµÄ·½·¨À´Ê¹Óã¬KeyStokeÀàÌṩÁ˼¸¸ö"À¦"¼üµÄ¾²Ì¬ÖØ
ÔØ·½·¨£¬ÏÂÃæËµ¼¸¸öÀý×Ó£¬ÄãÃÇ×Ô¼ºÈ¥ÊÔÊÔ°É£º
F5£º KeyStroke.getKeyStroke(KeyEvent.F5, 0);
Ctrl+Q£º KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_MASK);
a£ºKeyStroke. getKeyStroke('a');
Alt+Shift+C£ºgetKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK |
InputEvent.SHIFT_MASK, true);
µ±È»£¬Èç¹ûÄã²»ÏëÒýÈëһЩÈçKeyEvent»òInputEventÀàµÄ»°£¬ÄÇôÄã¾Í¿ÉÒÔÓÃ
KeyStroke.getKeyStroke(String s)·½·¨À´¼ò»¯Ëû£º
F5£ºKeyStroke.getKeyStroke("F5");
Ctrl+Q£ºKeyStroke.getKeyStroke("control Q ");
a£ºKeyStroke.getKeyStroke( "typed a" );
Alt+Shift+C£ºgetKeyStroke("alt shift released X ");
ÈçΪ×Ӳ˵¥"´ò¿ª"(ÃûΪ£ºmeuOpen)¼ÓÈë¿ì½Ý¼üCtrl+O£º
meuOpen.setAccelerator(KeyStroke.getKeyStroke("control O"));
ÉÏÃæËµµÄÊÇ×Ӳ˵¥µÄ¿ì½Ý¼üÉèÖã¬ÏÖÔÚ˵ÏÂÆäËü¿Ø¼þµÄ¿ì½Ý¼üÉèÖãº
°Ñ¿ª°ïÖúÎļþ£¬½øÈë javax.swing.AbstractButton £¬Äã¿ÉÒÔÕÒµ½setMnemonic
(int mnemonic)£¬Õâ¾ÍÊÇAbstractButton×ÓÀàÉèÖÿì½Ý¼üµÄ·½·¨ÁË£¬ÈçÒ»¸ö°´Å¥
btn£¬ÉèÖÿì½Ý¼üΪ£ºbtn.setMnemonic (KeyEvent.A)£¬ÔòËüµÄ¿ì½Ý·½Ê½ÎªAlt+A
£¬ËüÓÐÒ»¸öÐÞÊη½·¨ setDisplayedMnemonicIndex (int index)£¬×÷ÓÃÊÇÉèÖñê
ÌâµÄµÚ¼¸¸ö×Ö·û¼Ó¸öÏ»®ÏßÀ´±êʶ¿ì½Ý¼ü£¬Èçbtn.setText
("Open");btn.setDisplayedMnemonicIndex(0)£¬ÔòbtnµÄ±êÌâ±äΪOpen¡£
´ÏÃ÷µÄÄãÃÇÍ»ÀàÅÔͨ°É£¬Ò»¶¨¿ÉÒԳɹ¦µÄ¡£²»¹ýҪעÒâÒÔϼ¸µã£º
1¡¢ÔÚʹÓÃKeyStrokeµÄgetKeyStroke(String s)·½·¨Ê±Ó¦¸Ã×¢ÒâÓ÷¨ÈçCtrlÓÃ
control±íʾ£¬AltÓÃaltÀ´±íʾ£¬Èç¹û¼ÓÉÏ×ÖĸÔòÒªÓôóд£¬µ«Ö»ÓÐÒ»¸ö¼üÈçaʱ
£¬Ó¦¸ÃÓÃСд£º"type a"¡£
2¡¢KeyStroke
Ïà¹ØÎĵµ£º
Java°æÖ§¸¶±¦½Ó¿Ú¿ª·¢
ÐèÇ󣺵÷ÓÃÖ§¸¶±¦½Ó¿ÚµÄ½Ó¿Ú²¢¼¯³Éµ½É̳Ç
µ÷ÓÃÖ§¸¶±¦½Ó¿ÚËùÐèÒªµÄ“Ö§¸¶±¦ºÏ×÷»ï°éid”ºÍ“Ö§¸¶±¦°²È«Ð£ÑéÂ딹«Ë¾¶¼¸øÌṩºÃÁË£¬Ö§¸¶±¦¹Ù·½ÄÇÀïÒ²ÓиýӿڵēʵÎïÉÌÆ·½»Ò×·þÎñ¼¯³É¼¼ÊõÎĵµ”¼°Ïà¹ØµÄDEMOÔ´Âë¡£¹«Ë¾ÈÃÎÒÓÃJAVAÀ´Ð´£¬ÖÕÓÚÔÝʱ²»ÓÃÔÙдJSÁË£¬ºÙºÙ&hel ......
¶ÔÓÚ½«ÒªÊ¹ÓõÄJSP¹æ·¶µÄÒ»¸öÌØµã£¬¾ÍÊÇJSP±í´ïʽÓïÑÔ¡£Ôںܴó³Ì¶ÈÉÏ£¬ËüÊÇÓÐÒâ¼ò»¯µÄ£¬²¢¶ÀÁ¢ÓÚJSP¡£
ÔÚJSPµÄÔçÆÚ°æ±¾ÖУ¬Java´úÂëÒԽű¾µÄÐÎʽǶÈëµ½JSPÒ³ÃæÖУ¬ÀýÈ磺
<%
MyBean bean = new MyBean();
String name = bean.getName();
out.println(name);
%>
Õâ¸ö½Å±¾´úÂëн¨ÁËÒ»¸öÃûΪMyBeanµÄʵÀý£¬»ñµÃË ......
ÀûÓÃJNI¼¼Êõ£¬¿ÉÒÔ×öµ½C/C++ÓëJavaÖ®¼äµÄÏ໥µ÷Óá£
1¡¢Javaµ÷ÓÃC/C++½Ó¿Ú
Õâ¸öÊÇJNI×î»ù±¾µÄÓ¦Óã¬JNIÓкܶàÕâ·½ÃæµÄÀý×Ó´úÂë¡£Ò»°ã°ÑC/C++д³É¶¯Ì¬Á´½Ó¿â£»ÔÚJava³ÌÐòÔÚLoadLibrary£¬ÀûÓÃnative½Ó¿Ú£¬¼´¿ÉÍê³Éµ÷Óá£
2¡¢C/C++»Øµ÷Java½Ó¿Ú
ÕâÖÖÓ÷¨£¬JNIµÄÀý×ӱȽÏÉÙ¡£Æäʵ£¬Ò²±È½Ï¼òµ¥£¬JNIÒ²ÌṩÁËÕâÑùµÄ½Ó¿Ú¡ ......
JAVA_HOME:
C:\Java\jdk1.6.0_17
Path:
%JAVA_HOME%\bin
ClassPath:
.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar
ÎÒÃÇÐèÒªÉèÖÃÈý¸ö»·¾³±äÁ¿£ºJAVA_HOME¡¢PATH ºÍ CLASSPATH¡£
JAVA_HOME£º¸Ã»·¾³±äÁ¿µÄÖµ¾ÍÊÇ Java ËùÔÚµÄĿ¼£¬Ò»Ð© Java °æµÄÈí¼þºÍÒ»
Щ Java µÄ¹¤¾ßÐèÒªÓõ½¸Ã±äÁ¿£¬ÉèÖà PATH ºÍ CLASSP ......
java³£ÓÃÀàµÄʹÓ÷½·¨
Interger£ºÕûÊýÀàÐÍ
£±¡¢ÊôÐÔ¡£
static int MAX_VALUE£º·µ»Ø×î´óµÄÕûÐÍÊý£»
static int MIN_VALUE£º·µ»Ø×îСµÄÕûÐÍÊý£»
static Class TYPE £º·µ»Øµ±Ç°ÀàÐÍ¡£
Àý×Ó£º
´úÂë:
System.out.println("Integer.MAX_VALUE: " + Integer.MAX_VALUE );
½á¹ûΪ£ºInteger.MAX_VALUE: 2147483647
&nb ......