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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? command.java

?? These are the examples from the book Java Examples in a Nutshell, 2nd Edition, by David Flanagan.
?? JAVA
字號:
/* * 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();	}    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区大片| 色天使色偷偷av一区二区| 亚洲成人精品一区二区| 专区另类欧美日韩| 中文字幕日韩av资源站| 国产精品无码永久免费888| 亚洲国产精品成人综合| 久久久91精品国产一区二区三区| 精品国产不卡一区二区三区| 亚洲精品在线免费观看视频| 精品成人免费观看| 精品成人佐山爱一区二区| 欧美成人一区二区| www成人在线观看| 久久久天堂av| 国产精品久久一卡二卡| 亚洲免费大片在线观看| 亚洲在线视频一区| 免费人成网站在线观看欧美高清| 久久精品72免费观看| 久久精品国内一区二区三区| 国产精品一级片| 国产高清成人在线| 91免费看`日韩一区二区| 欧美乱妇20p| 久久精品一二三| ㊣最新国产の精品bt伙计久久| 亚洲综合图片区| 精品系列免费在线观看| jvid福利写真一区二区三区| 欧美日韩免费在线视频| 欧美成人video| 国产精品理论在线观看| 午夜精品福利视频网站| 极品瑜伽女神91| 99国产精品视频免费观看| 91精品一区二区三区在线观看| 久久精品网站免费观看| 视频在线观看一区二区三区| 国产成人aaa| 欧美喷水一区二区| 国产欧美日韩综合精品一区二区| 亚洲男人的天堂在线aⅴ视频| 久久精品国产99国产| 色婷婷综合激情| 国产日韩精品视频一区| 美女一区二区三区| 在线观看免费一区| 中文字幕国产一区| 久久国内精品视频| 欧美精品1区2区| 亚洲伦在线观看| 成人av网站免费| 久久久久久久电影| 久久99蜜桃精品| 3atv一区二区三区| 亚洲一区二区三区四区中文字幕| 国产盗摄精品一区二区三区在线 | 不卡大黄网站免费看| 91精品国产综合久久精品app| 国产精品久久久久久久久搜平片 | 欧美精品一区二区三区高清aⅴ | 国产午夜亚洲精品午夜鲁丝片| 五月综合激情婷婷六月色窝| 91在线观看高清| 国产精品久久久久久久蜜臀| 国产福利一区二区| 久久―日本道色综合久久| 理论电影国产精品| 欧美一级片免费看| 麻豆成人久久精品二区三区红 | 成人一区二区三区视频| 精品成人一区二区三区四区| 精品一区二区在线视频| 欧美日本在线视频| 天堂午夜影视日韩欧美一区二区| 色八戒一区二区三区| 1024国产精品| 91在线免费播放| 亚洲精品成人天堂一二三| 成人免费视频国产在线观看| 久久久久久一二三区| caoporn国产精品| 国产精品高潮久久久久无| 成人激情午夜影院| 亚洲手机成人高清视频| 欧美亚洲愉拍一区二区| 亚洲午夜精品17c| 欧美精品v日韩精品v韩国精品v| 亚洲v精品v日韩v欧美v专区| 欧美一卡二卡在线观看| 国产精品一区在线观看你懂的| 国产欧美一区二区精品婷婷| bt7086福利一区国产| 18欧美亚洲精品| 欧美精品xxxxbbbb| 国产老妇另类xxxxx| 亚洲色图在线播放| 欧美影院一区二区| 国内精品久久久久影院一蜜桃| 国产日产欧美一区二区视频| 色婷婷精品大在线视频| 偷拍日韩校园综合在线| 欧美一级精品在线| 91亚洲永久精品| 轻轻草成人在线| 中文字幕不卡三区| 在线观看国产一区二区| 九九精品视频在线看| 亚洲免费在线电影| 欧美videos中文字幕| 99国产精品一区| 精品亚洲免费视频| 一区二区三区av电影| 精品蜜桃在线看| 欧美影院一区二区三区| 成人自拍视频在线| 免费在线看成人av| 亚洲欧美日韩在线| 久久精品水蜜桃av综合天堂| 欧美喷潮久久久xxxxx| 成人av影视在线观看| 免费视频最近日韩| 夜夜嗨av一区二区三区四季av| xnxx国产精品| 欧美日韩视频在线第一区| 成人高清伦理免费影院在线观看| 日本不卡一区二区三区高清视频| 1区2区3区国产精品| 久久精品人人做| 日韩免费视频一区| 91麻豆精品91久久久久同性| 色综合色狠狠天天综合色| 丁香天五香天堂综合| 精品一区二区综合| 麻豆成人久久精品二区三区小说| 亚洲不卡一区二区三区| 亚洲美女在线国产| 一区二区三区日韩欧美精品| 中文字幕在线观看不卡| 久久精品日韩一区二区三区| 亚洲精品在线观| 精品999在线播放| 日韩免费一区二区三区在线播放| 91精品国产91久久久久久最新毛片| 在线一区二区三区四区五区| 97久久精品人人澡人人爽| 成人午夜在线免费| 成人aa视频在线观看| 99久久免费精品| 91丨porny丨首页| 91丨九色丨蝌蚪丨老版| 99久久精品99国产精品| 99久久精品国产毛片| 97久久精品人人澡人人爽| 93久久精品日日躁夜夜躁欧美| 91在线免费视频观看| 91色九色蝌蚪| 欧美视频在线播放| 欧美精品丝袜中出| 欧美一区二区三区公司| 欧美精品一区二区三区在线播放| 日韩午夜激情免费电影| 久久婷婷成人综合色| 国产精品系列在线| 亚洲美女在线一区| 青青青伊人色综合久久| 狠狠色狠狠色综合系列| 国精产品一区一区三区mba桃花| 久久99久久久欧美国产| 国产91丝袜在线18| 色偷偷久久人人79超碰人人澡| 91成人在线免费观看| 91精品国产麻豆| 久久精品欧美日韩| 亚洲在线成人精品| 久久99精品久久久久| www.欧美色图| 欧美喷潮久久久xxxxx| 久久久午夜电影| 亚洲国产另类av| 国产一区 二区| 一本久道中文字幕精品亚洲嫩| 欧美高清视频不卡网| 亚洲国产精品v| 久久精品国产一区二区三区免费看| 国产一二精品视频| 欧日韩精品视频| 国产欧美日韩综合精品一区二区| 亚洲午夜影视影院在线观看| 国内外成人在线| 欧美色网站导航| 欧美国产精品一区| 日韩av中文字幕一区二区| eeuss鲁一区二区三区| 精品成人一区二区三区| 亚洲一区二区不卡免费| 成人在线综合网| 久久婷婷色综合| 青青国产91久久久久久|