亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? command.java

?? Examples From Java Examples in a Nutshell, 2nd Edition 書中的源碼
?? JAVA
字號(hào):
/* * Copyright (c) 2000 David Flanagan.  All rights reserved. * This code is from the book Java Examples in a Nutshell, 2nd Edition. * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied. * You may study, use, and modify it for any non-commercial purpose. * You may distribute it non-commercially as long as you retain this notice. * For a commercial use license, or to purchase the book (recommended), * visit http://www.davidflanagan.com/javaexamples2. */package com.davidflanagan.examples.reflect;import java.awt.event.*;import java.beans.*;import java.lang.reflect.*;import java.io.*;import java.util.*;/** * This class represents a Method, the list of arguments to be passed * to that method, and the object on which the method is to be invoked. * The invoke() method invokes the method.  The actionPerformed() method * does the same thing, allowing this class to implement ActionListener * and be used to respond to ActionEvents generated in a GUI or elsewhere.  * The static parse() method parses a string representation of a method * and its arguments. **/public class Command implements ActionListener {    Method m;       // The method to be invoked    Object target;  // The object to invoke it on    Object[] args;  // The arguments to pass to the method    // An empty array; used for methods with no arguments at all.    static final Object[] nullargs = new Object[] {};        /** This constructor creates a Command object for a no-arg method */    public Command(Object target, Method m) { this(target, m, nullargs); }    /**      * This constructor creates a Command object for a method that takes the     * specified array of arguments.  Note that the parse() method provides     * another way to create a Command object     **/    public Command(Object target, Method m, Object[] args) { 	this.target = target;	this.m = m;	this.args = args;    }    /**     * Invoke the Command by calling the method on its target, and passing     * the arguments.  See also actionPerformed() which does not throw the     * checked exceptions that this method does.     **/    public void invoke()	throws IllegalAccessException, InvocationTargetException    {	m.invoke(target, args);  // Use reflection to invoke the method    }    /**     * This method implements the ActionListener interface.  It is like     * invoke() except that it catches the exceptions thrown by that method     * and rethrows them as an unchecked RuntimeException     **/    public void actionPerformed(ActionEvent e) {	try {	    invoke();                           // Call the invoke method	}	catch (InvocationTargetException ex) {  // but handle the exceptions	    throw new RuntimeException("Command: " + 				       ex.getTargetException().toString());	}	catch (IllegalAccessException ex) { 	    throw new RuntimeException("Command: " + ex.toString());	}    }    /**     * This static method creates a Command using the specified target object,     * and the specified string.  The string should contain method name     * followed by an optional parenthesized comma-separated argument list and     * a semicolon.  The arguments may be boolean, integer or double literals,     * or double-quoted strings.  The parser is lenient about missing commas,     * semicolons and quotes, but throws an IOException if it cannot parse the     * string.     **/    public static Command parse(Object target, String text) throws IOException    {	String methodname;                 // The name of the method	ArrayList args = new ArrayList();  // Hold arguments as we parse them.	ArrayList types = new ArrayList(); // Hold argument types.	// Convert the string into a character stream, and use the	// StreamTokenizer class to convert it into a stream of tokens	StreamTokenizer t = new StreamTokenizer(new StringReader(text));	// The first token must be the method name	int c = t.nextToken();  // read a token	if (c != t.TT_WORD)     // check the token type	    throw new IOException("Missing method name for command");	methodname = t.sval;    // Remember the method name	// Now we either need a semicolon or a open paren	c = t.nextToken();	if (c == '(') { // If we see an open paren, then parse an arg list	    for(;;) {                   // Loop 'till end of arglist		c = t.nextToken();      // Read next token		if (c == ')') {         // See if we're done parsing arguments.		    c = t.nextToken();  // If so, parse an optional semicolon		    if (c != ';') t.pushBack();		    break;              // Now stop the loop.		}		// Otherwise, the token is an argument; figure out its type		if (c == t.TT_WORD) {		    // If the token is an identifier, parse boolean literals, 		    // and treat any other tokens as unquoted string literals.		    if (t.sval.equals("true")) {       // Boolean literal			args.add(Boolean.TRUE);			types.add(boolean.class);		    }		    else if (t.sval.equals("false")) { // Boolean literal			args.add(Boolean.FALSE);			types.add(boolean.class);		    }		    else {                             // Assume its a string			args.add(t.sval);			types.add(String.class);		    }		}		else if (c == '"') {         // If the token is a quoted string		    args.add(t.sval);		    types.add(String.class);		}		else if (c == t.TT_NUMBER) { // If the token is a number		    int i = (int) t.nval;		    if (i == t.nval) {           // Check if its an integer			// Note: this code treats a token like "2.0" as an int!			args.add(new Integer(i));			types.add(int.class);		    }		    else {                       // Otherwise, its a double			args.add(new Double(t.nval));			types.add(double.class);		    }		}		else {                        // Any other token is an error		    throw new IOException("Unexpected token " + t.sval +					  " in argument list of " +					  methodname + "().");		}		// Next should be a comma, but we don't complain if its not 		c = t.nextToken();		if (c != ',') t.pushBack();	    }	}	else if (c != ';') { // if a method name is not followed by a paren  	    t.pushBack();    // then allow a semi-colon but don't require it.	}	// We've parsed the argument list.	// Next, convert the lists of argument values and types to arrays	Object[] argValues = args.toArray();	Class[] argtypes = (Class[])types.toArray(new Class[argValues.length]);	// At this point, we've got a method name, and arrays of argument	// values and types.  Use reflection on the class of the target object	// to find a method with the given name and argument types.  Throw	// an exception if we can't find the named method.	Method method;	try { method = target.getClass().getMethod(methodname, argtypes); }	catch (Exception e) {	    throw new IOException("No such method found, or wrong argument " +				  "types: " + methodname);	}	// Finally, create and return a Command object, using the target object	// passed to this method, the Method object we obtained above, and	// the array of argument values we parsed from the string.	return new Command(target, method, argValues);    }    /**     * This simple program demonstrates how a Command object can be parsed from     * a string and used as an ActionListener object in a Swing application.     **/    static class Test {	public static void main(String[] args) throws IOException {	    javax.swing.JFrame f = new javax.swing.JFrame("Command Test");	    javax.swing.JButton b1 = new javax.swing.JButton("Tick");	    javax.swing.JButton b2 = new javax.swing.JButton("Tock");	    javax.swing.JLabel label = new javax.swing.JLabel("Hello world");	    java.awt.Container pane = f.getContentPane();	    pane.add(b1, java.awt.BorderLayout.WEST);	    pane.add(b2, java.awt.BorderLayout.EAST);	    pane.add(label, java.awt.BorderLayout.NORTH);	    b1.addActionListener(Command.parse(label, "setText(\"tick\");"));	    b2.addActionListener(Command.parse(label, "setText(\"tock\");"));	    	    f.pack();	    f.show();	}    }}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本不卡高清视频| 欧美天天综合网| 欧洲色大大久久| 久久九九国产精品| 午夜精品一区在线观看| 国产99久久久精品| 日韩一级高清毛片| 亚洲一二三四在线观看| 成人av动漫在线| 精品久久五月天| 日韩精品成人一区二区三区| 国产91丝袜在线播放| 日韩欧美国产高清| 亚洲18女电影在线观看| 91色在线porny| 国产精品系列在线| 韩国精品在线观看| 日韩欧美在线网站| 首页欧美精品中文字幕| 91福利社在线观看| 日韩美女视频19| 99精品国产99久久久久久白柏| 久久综合成人精品亚洲另类欧美| 日韩国产精品久久| 欧美视频你懂的| 亚洲无线码一区二区三区| 色悠悠久久综合| 国产精品成人在线观看| 成人黄色av电影| 中文字幕成人av| 成人午夜激情影院| 亚洲国产精品传媒在线观看| 国产一区视频网站| 国产亚洲欧美在线| 国产一区二区在线看| 精品国产百合女同互慰| 老司机精品视频导航| 日韩一级二级三级精品视频| 青椒成人免费视频| 欧美成人精品高清在线播放| 久久69国产一区二区蜜臀| 日韩一区二区三区在线| 精品伊人久久久久7777人| 精品久久久久一区| 丁香六月综合激情| 亚洲男女一区二区三区| 欧美日韩精品欧美日韩精品一| 亚洲福利视频一区二区| 91精品国产入口| 久久国产婷婷国产香蕉| 国产亚洲欧美在线| 色婷婷狠狠综合| 亚洲va中文字幕| 精品国产在天天线2019| 丁香婷婷深情五月亚洲| 一区二区日韩电影| 777午夜精品免费视频| 奇米888四色在线精品| 久久久综合视频| 91亚洲国产成人精品一区二三| 亚洲高清免费一级二级三级| 日韩三级视频在线看| 国产成人啪免费观看软件| 亚洲日本在线天堂| 日韩精品专区在线| av中文字幕不卡| 日韩精品欧美精品| 中文字幕第一区第二区| 欧美日韩国产bt| 国产69精品久久久久777| 尤物在线观看一区| 亚洲精品在线观| 欧美性色黄大片| 国产一区二区不卡老阿姨| 亚洲精品久久嫩草网站秘色| 欧美一区二区三区在线观看视频| 国产·精品毛片| 日本女人一区二区三区| 中文av字幕一区| 精品久久久久av影院 | 日韩情涩欧美日韩视频| 成年人网站91| 麻豆一区二区三区| 一区二区三区蜜桃网| 26uuu亚洲| 91精品在线观看入口| 色综合中文综合网| 国产午夜亚洲精品理论片色戒| 欧美少妇xxx| 成人深夜在线观看| 精品一区二区三区蜜桃| 亚洲一区二区视频在线| 中文字幕一区免费在线观看| 欧美一区二区精品在线| 欧美在线制服丝袜| 成人黄色在线看| 国产精品夜夜爽| 久久精品99国产精品日本| 亚洲a一区二区| 一区二区三区高清不卡| 国产精品美女久久久久av爽李琼 | 久久先锋资源网| 欧美片在线播放| 欧美午夜理伦三级在线观看| a亚洲天堂av| 成人网页在线观看| 国产成人高清视频| 风流少妇一区二区| 国产精品2024| 国产超碰在线一区| 国产东北露脸精品视频| 国产一区二区不卡在线| 狠狠色狠狠色合久久伊人| 蜜桃av一区二区三区电影| 日韩精品成人一区二区在线| 午夜精品一区二区三区三上悠亚| 亚洲综合久久久| 亚洲福利视频三区| 日日夜夜免费精品| 全国精品久久少妇| 精品在线免费观看| 国产成人午夜精品影院观看视频 | 午夜av一区二区三区| 亚洲成a天堂v人片| 日韩激情视频网站| 久久精品国产亚洲aⅴ| 久久99国产精品久久99果冻传媒| 久久99精品久久久久久| 国产成人免费在线观看不卡| 粉嫩13p一区二区三区| 不卡的av电影| 日本精品视频一区二区| 欧美日韩国产不卡| 久久一区二区三区国产精品| 欧美国产日韩在线观看| 亚洲另类中文字| 天堂蜜桃一区二区三区| 精品综合免费视频观看| 国产91精品欧美| 欧美怡红院视频| 日韩欧美一区电影| 中文字幕中文在线不卡住| 一区二区三区视频在线看| 日韩va亚洲va欧美va久久| 国内精品伊人久久久久av一坑| 成人午夜碰碰视频| 欧美日韩一级二级| 国产三级精品在线| 亚洲一区二区综合| 狠狠色丁香久久婷婷综合丁香| 成人免费不卡视频| 欧美剧在线免费观看网站| 久久婷婷久久一区二区三区| 中文字幕中文字幕一区二区| 天堂va蜜桃一区二区三区| 91丨porny丨蝌蚪视频| 欧美色图在线观看| 久久久影视传媒| 亚洲chinese男男1069| 国产乱一区二区| 欧美日韩国产在线播放网站| 久久天天做天天爱综合色| 一区二区三区精密机械公司| 精品一区二区三区影院在线午夜| voyeur盗摄精品| 精品sm在线观看| 亚洲五码中文字幕| av在线不卡电影| 精品美女被调教视频大全网站| 亚洲黄色免费网站| 国产精品99久| 欧美成人精品福利| 午夜电影网一区| 一本一本久久a久久精品综合麻豆| 欧美成人一区二区| 亚洲va欧美va人人爽| 99这里都是精品| 久久久久久久久久久电影| 日韩二区三区在线观看| 91一区二区三区在线观看| 久久久不卡影院| 奇米一区二区三区| 欧美区在线观看| 亚洲一区国产视频| 在线影视一区二区三区| 亚洲国产激情av| 国产成人日日夜夜| 久久精品亚洲精品国产欧美| 青青草国产成人av片免费| 欧美日韩亚洲综合一区二区三区| 亚洲色图在线看| www.欧美色图| 国产精品色哟哟| 成人福利视频在线| 国产精品人妖ts系列视频| 国产精品一级二级三级| 国产三级精品视频| 岛国一区二区三区| 一区在线播放视频| 99riav一区二区三区|