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

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

?? command.java

?? 164個java例程
?? 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一区二区三区免费野_久草精品视频
色综合天天性综合| 老司机精品视频一区二区三区| 成人精品视频一区二区三区尤物| 精品国产123| 国产精品影音先锋| 久久精品夜色噜噜亚洲aⅴ| 国产成a人亚洲精| 中文字幕一区在线观看| 色偷偷成人一区二区三区91| 亚洲一级片在线观看| 欧美精品在欧美一区二区少妇| 日本亚洲视频在线| 国产女主播一区| 91网站在线观看视频| 亚洲va韩国va欧美va精品| 日韩免费观看高清完整版| 国产精品一级在线| 亚洲精品欧美激情| 日韩精品一区二区三区四区视频 | 国精产品一区一区三区mba桃花| 欧美精品国产精品| 国产精品一区一区三区| 亚洲精品中文在线影院| 日韩美女一区二区三区四区| 不卡av电影在线播放| 婷婷丁香久久五月婷婷| 久久久精品一品道一区| 色综合中文字幕国产 | 成人a区在线观看| 亚洲一区影音先锋| 久久精品一二三| 欧美日本一道本| 91影院在线观看| 午夜激情综合网| 国产日韩av一区| 欧美挠脚心视频网站| 国产成+人+日韩+欧美+亚洲| 亚洲3atv精品一区二区三区| 国产日本欧美一区二区| 欧美精选在线播放| av欧美精品.com| 久久国产尿小便嘘嘘尿| 一区二区三区在线视频免费观看| 欧美α欧美αv大片| 一本到不卡免费一区二区| 国产一区欧美日韩| 亚洲444eee在线观看| 中文字幕中文字幕一区| 日韩三级伦理片妻子的秘密按摩| 成人18精品视频| 狠狠久久亚洲欧美| 日韩黄色一级片| 亚洲综合av网| 亚洲天堂2016| 国产女人aaa级久久久级| 制服丝袜在线91| 日本道精品一区二区三区| 国产精品18久久久久| 日本伊人色综合网| 亚洲国产婷婷综合在线精品| 中文字幕一区二区三区四区不卡 | 亚洲欧洲在线观看av| 2023国产精品视频| 精品少妇一区二区三区免费观看 | 国产成人午夜视频| 极品少妇xxxx偷拍精品少妇| 日本伊人色综合网| 日本不卡一区二区三区| 五月天激情综合网| 亚洲成人自拍网| 亚洲成va人在线观看| 一区二区视频在线看| 亚洲欧美国产三级| 中文字幕一区二区不卡| 国产精品无遮挡| 中文字幕av一区 二区| 中文成人综合网| 亚洲国产精品99久久久久久久久| 久久综合九色综合欧美亚洲| 精品999久久久| 久久蜜桃香蕉精品一区二区三区| 久久嫩草精品久久久精品一| 久久久综合九色合综国产精品| 久久亚洲综合av| 国产欧美久久久精品影院| 国产调教视频一区| 中文字幕在线播放不卡一区| 亚洲精品欧美综合四区| 亚洲一线二线三线视频| 日韩av不卡在线观看| 激情综合五月天| 国产91丝袜在线播放0| 成人av在线电影| 色噜噜狠狠一区二区三区果冻| 欧美亚洲丝袜传媒另类| 91麻豆精品国产无毒不卡在线观看| 91精品婷婷国产综合久久性色| 欧美一级免费大片| www国产精品av| 亚洲视频免费看| 午夜精品一区在线观看| 国内一区二区视频| 99久久精品免费看国产| 欧美日韩精品欧美日韩精品一综合| 欧美一区二区网站| 久久久99精品免费观看| 亚洲图片欧美激情| 日本免费在线视频不卡一不卡二 | 午夜电影一区二区| 极品少妇一区二区三区精品视频| 成人精品鲁一区一区二区| 在线欧美日韩国产| 26uuu精品一区二区| 日韩一区有码在线| 久久精品国产亚洲一区二区三区| 成人深夜在线观看| 欧美三级日韩三级国产三级| 久久久亚洲欧洲日产国码αv| 亚洲黄色av一区| 激情深爱一区二区| 日本韩国一区二区| 久久久.com| 视频在线在亚洲| av一区二区三区四区| 日韩美女一区二区三区四区| 亚洲久本草在线中文字幕| 狠狠色综合日日| 日本韩国欧美一区二区三区| 欧美大尺度电影在线| 一区二区三区在线视频免费| 国产乱子轮精品视频| 欧美日韩在线三级| 国产三级一区二区三区| 午夜精品123| 91女厕偷拍女厕偷拍高清| 精品少妇一区二区三区在线播放| 亚洲综合激情小说| 国产传媒欧美日韩成人| 欧美精品久久99久久在免费线| 亚洲丝袜自拍清纯另类| 国产一区二区在线视频| 欧美日本在线看| 亚洲激情图片qvod| 北岛玲一区二区三区四区| 欧美精品一区二区三区四区| 日本网站在线观看一区二区三区| 色综合天天在线| 国产精品久久久久久久蜜臀| 国产乱人伦偷精品视频免下载| 欧美一区二区视频观看视频| 亚洲bt欧美bt精品777| 91网站黄www| 国产精品美女久久久久av爽李琼| 国产精品1区2区3区在线观看| 日韩欧美亚洲一区二区| 午夜精品影院在线观看| 欧美私模裸体表演在线观看| 亚洲精品美腿丝袜| 91捆绑美女网站| 中文字幕五月欧美| 菠萝蜜视频在线观看一区| 国产欧美久久久精品影院| 国产成人高清视频| 国产丝袜在线精品| 国产精品一二三区| 欧美国产亚洲另类动漫| 成人av网站在线| **性色生活片久久毛片| www.日韩av| 亚洲色欲色欲www在线观看| 色综合色综合色综合色综合色综合| 中文字幕视频一区| 欧洲中文字幕精品| 亚洲一区二区三区四区在线| 欧美精品精品一区| 奇米精品一区二区三区在线观看| 日韩免费一区二区| 国产精品中文字幕一区二区三区| 国产日韩精品一区二区三区| 成人午夜av电影| 成人欧美一区二区三区在线播放| 日本伦理一区二区| 午夜影院久久久| 精品成人一区二区三区四区| 国产精品123| 亚洲日韩欧美一区二区在线| 欧美日韩高清一区二区三区| 美腿丝袜亚洲色图| 欧美激情综合网| 91久久国产最好的精华液| 水蜜桃久久夜色精品一区的特点| 欧美电影免费观看高清完整版在线观看| 国产综合久久久久久久久久久久 | 亚洲欧美在线另类| 欧美日韩一卡二卡三卡 | 亚洲丰满少妇videoshd| 欧美一区二区三区四区视频| 国精产品一区一区三区mba视频| 中文字幕在线不卡视频| 欧美巨大另类极品videosbest |