Java´òÓ¡³ÌÐòÉè¼ÆÈ«¹¥ÂÔ
[ת]Java´òÓ¡³ÌÐòÉè¼ÆÈ«¹¥ÂÔ
2008-12-07 18:43
Ç°ÑÔ
¡¡¡¡ÔÚÎÒÃǵÄʵ¼Ê¹¤×÷ÖУ¬¾³£ÐèҪʵÏÖ´òÓ¡¹¦ÄÜ¡£µ«ÓÉÓÚÀúÊ·ÔÒò£¬JavaÌṩµÄ´òÓ¡¹¦ÄÜÒ»Ö±¶¼±È½ÏÈõ¡£Êµ¼ÊÉÏ×î³õµÄjdk¸ù±¾²»Ö§³Ö´òÓ¡£¬Ö±µ½jdk1.1²ÅÒýÈëÁ˺ÜÇáÁ¿µÄ´òÓ¡Ö§³Ö¡£ËùÒÔ£¬ÔÚÒÔÇ°ÓÃJava/Applet/JSP/ServletÉè¼ÆµÄ³ÌÐòÖУ¬½Ï¸´ÔӵĴòÓ¡¶¼ÊÇͨ¹ýµ÷ÓÃActiveX/OCX¿Ø¼þ»òÕßVB/VC³ÌÐòÀ´ÊµÏֵģ¬·Ç³£Âé·³¡£Êµ¼ÊÉÏ£¬SUN¹«Ë¾Ò²Ò»Ö±ÖÂÁ¦ÓÚJava´òÓ¡¹¦ÄܵÄÍêÉÆ£¬¶øJava2ƽ̨ÔòÖÕÓÚÓÐÁËÒ»¸ö½¡×³µÄ´òӡģʽµÄ¿ª¶Ë£¬¸Ã´òӡģʽÓëJava2DͼÐΰü³ä·Ö½áºÏ³ÉÒ»Ìå¡£¸üÁîÈ˹ÄÎèµÄÊÇ£¬Ð·¢²¼µÄjdk1.4ÔòÌṩÁËÒ»Ì×ÍêÕûµÄ"Java ´òÓ¡·þÎñ API" (Java Print Service API)£¬Ëü¶ÔÒÑÓеĴòÓ¡¹¦ÄÜÊÇ»ý¼«µÄ²¹³ä¡£ÀûÓÃËü£¬ÎÒÃÇ¿ÉÒÔʵÏִ󲿷Öʵ¼ÊÓ¦ÓÃÐèÇ󣬰üÀ¨´òÓ¡ÎÄ×Ö¡¢Í¼ÐΡ¢Îļþ¼°´òÓ¡Ô¤ÀÀµÈµÈ¡£±¾ÎĽ«Í¨¹ýÒ»¸ö¾ßÌåµÄ³ÌÐòʵÀýÀ´ËµÃ÷ÈçºÎÉè¼ÆJava´òÓ¡³ÌÐòÒÔʵÏÖÕâЩ¹¦ÄÜ£¬²¢¶Ô²»Í¬°æ±¾µÄʵÏÖ·½·¨½øÐзÖÎö±È½Ï,Ï£Íû´ó¼ÒÄÜ´ÓÖлñȡһЩÓÐÒæµÄÌáʾ¡£
¡¡¡¡JavaÖеĴòÓ¡
¡¡¡¡1¡¢JavaµÄ´òÓ¡API
¡¡¡¡JavaµÄ´òÓ¡APIÖ÷Òª´æÔÚÓÚjava.awt.print°üÖС£¶øjdk1.4ÐÂÔöµÄÀàÔòÖ÷Òª´æÔÚÓÚjavax.print°ü¼°ÆäÏàÓ¦µÄ×Ó°üjavax.print.eventºÍjavax.print.attributeÖС£ÆäÖÐjavax.print°üÖÐÖ÷Òª°üº¬´òÓ¡·þÎñµÄÏà¹ØÀ࣬¶øjavax.print.eventÔò°üº¬´òӡʼþµÄÏà¹Ø¶¨Ò壬javax.print.attributeÔò°üÀ¨´òÓ¡·þÎñµÄ¿ÉÓÃÊôÐÔÁбíµÈ¡£
¡¡¡¡2¡¢ÈçºÎʵÏÖ´òÓ¡
¡¡¡¡Òª²úÉúÒ»¸ö´òÓ¡£¬ÖÁÉÙÐèÒª¿¼ÂÇÁ½Ìõ£º
¡¡¡¡ÐèÒªÒ»¸ö´òÓ¡·þÎñ¶ÔÏó¡£Õâ¿Éͨ¹ýÈýÖÖ·½Ê½ÊµÏÖ£ºÔÚjdk1.4֮ǰµÄ°æ±¾£¬±ØÐëҪʵÏÖjava.awt.print.Printable½Ó¿Ú»òͨ¹ýToolkit.getDefaultToolkit().getPrintJobÀ´»ñÈ¡´òÓ¡·þÎñ¶ÔÏó£»ÔÚjdk1.4ÖÐÔò¿ÉÒÔͨ¹ýjavax.print.PrintSerivceLookupÀ´²éÕÒ¶¨Î»Ò»¸ö´òÓ¡·þÎñ¶ÔÏó¡£
¡¡¡¡ÐèÒª¿ªÊ¼Ò»¸ö´òÓ¡¹¤×÷¡£ÕâÒ²Óм¸ÖÖʵÏÖ·½·¨£ºÔÚjdk1.4֮ǰ¿ÉÒÔͨ¹ýjava.awt.print.PrintJob(jdk1.1ÌṩµÄ£¬ÏÖÔÚÒѾºÜÉÙÓÃÁË)µ÷ÓÃprint»òprintAll·½·¨¿ªÊ¼´òÓ¡¹¤×÷£»Ò²¿ÉÒÔͨ¹ýjava.awt.print.PrinterJobµÄprintDialogÏÔʾ´òÓ¡¶Ô»°¿ò£¬È»ºóͨ¹ýprint·½·¨¿ªÊ¼´òÓ¡£»ÔÚjdk1.4ÖÐÔò¿ÉÒÔͨ¹ýjavax.print.ServiceUIµÄprintDialogÏÔʾ´òÓ¡¶Ô»°¿ò£¬È»ºóµ÷ÓÃprint·½·¨¿ªÊ¼Ò»¸ö´òÓ¡¹¤×÷¡£
¡¡¡¡3¡¢´òÓ¡»ú¶Ô»°¿ò
¡¡¡¡3.1 PrintableµÄ´òÓ¡¶Ô»°¿ò
¡¡¡¡¿ªÊ¼´òÓ¡¹¤×÷֮ǰ£¬¿ÉÒÔͨ¹ýPrinterJob.printDialogÀ´ÏÔʾһ¸ö´òÓ¡¶Ô»°¿ò¡£Ëü¸øÓû§Ò»¸ö»ú»áÒÔÑ¡ÔñÓ¦¸Ã´òÓ¡µÄÒ³Â뷶Χ£¬²¢¿É¹©Óû§¸Ä±ä´ò
Ïà¹ØÎĵµ£º
Java¶ÔÏó¼°ÒýÓÃ
Java¶ÔÏó¼°ÒýÓÃÊÇÈÝÒ×»ìÏýÈ´ÓÖ±ØÐëÕÆÎյĻù´¡ÖªÊ¶£¬±¾Õ²ûÊöJava¶ÔÏóºÍÒýÓõĸÅÄÒÔ¼°ÓëÆäÃÜÇÐÏà¹ØµÄ²ÎÊý´«µÝ¡£
ÏÈ¿´ÏÂÃæµÄ³ÌÐò£º
StringBuffer s;
s = new StringBuffer("Hello World!");
µÚÒ»¸ö ......
/**
* µÃµ½±¾ÖÜÖÜÒ»
*
* @return yyyy-MM-dd
*/
public static String getMondayOfThisWeek() {
Calendar c = Calendar.getInstance();
int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
if (day_of_week == 0)
da ......
ת×Ô:http://hi.baidu.com/%C9%AE_%CC%C6/blog/item/9e2a8b0887008a8ad0581b3d.html
¼ò»¯Í¼£º
Javaƽ̨ÌṩÁËÒ»¸öȫеļ¯ºÏ¿ò¼Ü¡£“¼¯ºÏ¿ò¼Ü”Ö÷ÒªÓÉÒ»×éÓÃÀ´²Ù×÷¶ÔÏóµÄ½Ó¿Ú×é³É¡£²»Í¬½Ó¿ÚÃèÊöÒ»×鲻ͬÊý¾ÝÀàÐÍ¡£
Java 2¼¯ºÏ¿ò¼Üͼ
¼¯ºÏ½Ó¿Ú£º6¸ö½Ó¿Ú£¨¶ÌÐéÏß±íʾ£©£¬±íʾ²»Í¬¼¯ºÏÀàÐÍ£¬ÊǼ¯ºÏ¿ò¼Üµ ......