JavaʼþÄ£ÐÍѧϰ£¨2£©
µ±³ÌÐòµÄij¸öÄ£¿é±»µ÷ÓõÄʱ¿Ì²»È·¶¨£¬¾ÍÀàËÆÓڵȴýij¸öʼþµÄ·¢Éú¡£Õâʱ£¬¿ÉÒÔ¶¨Òå×Ô¼ºµÄʼþ½øÐÐÏàÓ¦µÄ´¦Àí¡£±ÈÈ磬µÈ´ýÓû§µÄÒ»´ÎÊäÈëµÈ¡£JavaµÄʼþÄ£ÐÍÒÀÀµÓÚίÍУ¬Í¨¹ý»Øµ÷·½·¨½øÐÐÏàÓ¦µÄʼþ´¦Àí¡£ÔÚʼþÔ´ÖУ¬»áÓÐfireXXXEvent()¾ÍÊǼ¤»îÏàÓ¦µÄʼþ£¬ÆäÖлá±éÀúʼþÔ´µÄ¼àÌýÆ÷¶ÓÁУ¬µ÷ÓÃÏàÓ¦¼àÌýÆ÷µÄʼþ´¦ÀíµÄ»Øµ÷·½·¨¡£µ±Ä³¸öʼþ·¢Éúʱ£¬Ê¼þÔ´»áµ÷ÓÃfireXXXEvent()¡£ÊµÏÖ×Ô¼ºµÄʼþʱ£¬ÐèÒª¶¨ÒåÏàÓ¦µÄʼþÀàÐÍ¡¢Ê¼þ¼àÌýÆ÷¡¢Ê¼þÔ´¡£ÕâÀï¿ÉÒÔ°ÑʼþºÍʼþÔ´¶¨ÒåΪ½Ó¿Ú£¬·½±ãÈÕºóÀ©Õ¹¡£
ÕâÀÎÒʵÏÖµÄʼþÊÇÒ»¸ö¶¨Ê±Æ÷ʼþ£¬µ±Ê±¼ä¹ýÁËÖ¸¶¨¼ä¸ô£¬´¥·¢Ê¼þ¡£Æäʵ£¬Ö»ÐèÒªÒ»¸öTimer¾Í¿ÉÒÔʵÏÖÕâ¸ö¹¦ÄÜ£¬µ«ÊµÔÚûÓÐÕÒµ½ºÃµÄÀý×Ó¡£Ê¼þÔ´ConcretEventSourceÓÐTimerÊôÐÔ£¬ÔÚÖ¸¶¨Ê±¼ä¼ä¸ôµ½´ïʱ£¬µ÷ÓÃfireTimeUp¼¤»îËùÓеÄʼþ¼àÌýÆ÷£¬´Ó¶øʵÏÖÁËʼþ´¦Àí¡£
ʼþÀà
package eventmodelstudy;
/**
* ¶¨Ê±Æ÷ʼþ£¬ÊôÐÔ¿ÉÒÔ±£´æÓÐÓõÄÐÅÏ¢£¬°üÀ¨Ê¼þÔ´
* @author Administrator
*/
public class TimerEvent {
private TimerEventSource source;//ʼþÔ´
private String time;//µ±Ç°Ê±¼ä
public TimerEvent(TimerEventSource source,String time){
this.source=source;
this.time=time;
}
public Object getSource(){
return this.source;
}
public String getTime(){
return this.time;
}
}
ʼþÔ´½Ó¿Ú
package eventmodelstudy;
/**
* ¶¨Ê±Æ÷ʼþÔ´½Ó¿Ú£¬¿ÉÒÔÌí¼Ó¡¢É¾³ý¶¨Ê±Æ÷ʼþ¼àÌýÆ÷
* @author Administrator
*/
public interface TimerEventSource {
public void addTimerListener(TimerListener tl);
public void removeTimerListener(TimerListener tl);
}
¾ßÌåʼþÔ´Àà
package eventmodelstudy;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.Timer;
/**
* ¶¨Ê±Æ÷ʼþÔ´¾ßÌåµÄʵÏÖÀà¡£µ±Ê±¼äµ½Ê±¼¤»î¼àÌýÆ÷£¬µ÷ÓÃËùÓмàÌýÆ÷µÄ»Øµ÷·½·¨»Øµ÷·½·¨
* @author Administrator
*/
public class ConcretEventSource implements TimerEventSource{
private Timer timer;
//¼àÌýÆ÷¶ÓÁУ¬±£´æËùÓÐ×
Ïà¹ØÎĵµ£º
ÏÖÔںܶàÈ˶¼ÎÊ C++ºÍJava ÄĸöºÃ. Æäʵ¼¼ÊõÉϸ÷Óи÷µÄºÃ´¦Óë²»×ã,ÎÒÏë´ó¼ÒËù˵µÄºÃ²»ºÃÖ¸µÃÊÇǰ;ºÃ²»ºÃ,׬µÄ¶à²»¶à.
Ҫ˵׬Ǯ×î¶àµÄ¿Ï¶¨ÊÇC++ÁË.ÒòΪһÃż¼ÊõÊÇ·ñֵǮȫ¿´»áËüµÄÈËÓжàÉÙ¶ø²»ÔÚÓÚÕâ¸ö¼¼Êõ±¾ÉíµÄºÃ»µ. C++Éæ¼°Ó²¼þµ×²ãµÄ¶«Î÷±È½Ï¶à,ѧÆðÀ´ºÜ¸´ÔÓ,»áµÄÈËÉÙ,ËùÒÔֵǮ.
&nb ......
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class Applet1 extends Applet implements ActionListener,ItemListener
{
TextArea mainText;
JTextField input;
JButton sendButton,disconnectButton,connectBu ......
Java SwingÖеÄJTreeÄ£ÐÍ
2009-01-04 10:40
±¾ÎĽéÉÜJava SwingÖеÄJTreeÄ£ÐÍ£¬½éÉÜÈçºÎ´´½¨¡¢Ð޸ġ¢±éÀú£¬ÉèÖÃÊ÷¡£²Î¿¼Core Java2Ïà¹ØÕ½ڼ°ÆäÔ´´úÂë¡£
SwingÊ÷ʹÓÃÈËÃÇËùÊìϤµÄÎļþ¼ÐºÍÊ÷ҶͼÀ´ÏÔʾ·Ö²ãµÄÊý¾Ý¡£Ê÷Óɽڵã×é³É£¬½Úµã¿ÉÒÔÊÇÎļþ¼Ð£¬Ò²¿ÉÒÔÊÇÊ÷Ò¶¡£Îļþ¼Ð¿ÉÒÔÓÐ×ӽڵ㣬³ý¸ù½ÚµãÖ®ÍâµÄËùÓнڵ㶼ֻÓÐÒ»¸ö¸ ......
ÒÔO(n)µÄʱ¼äʵÏÖ¶ÔÕýÕûÊýµÄÅÅÐò¡£Ë¼Â·ÊÇ£º´Ó×îĩλ¿ªÊ¼£¬¶ÔÊý×éÖÐÿһ¸öÊýµÄµÚkλ½øÐмÆÊýÅÅÐò£¬Ö±µ½Åŵ½×î¸ßλΪֹ¡£
ȱµã£ºÖ»ÄܶÔÕýÕûÊý½øÐÐÅÅÐò£¬¶øÇÒÐèÒªÖªµÀ×î´óÕûÊýµÄ×î¸ßλ£¬Ê¹Ó÷¶Î§Ì«Ð¡¡£µ«ÕⲻʧΪһ¸öºÜÓÐȤµÄÅÅÐò£¬ÒòΪËüµß¸²Á˱ȽÏÅÅÐòµÄ´«Í³Ë¼Â·¡£
public static int[] radixSort(int[] inputs,int d){
......