java´òÓ¡µÄÔ´´úÂë(ʾÀý)
package com.demo;
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.print.*;
import java.util.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.swing.*;
/**
This program demonstrates how to print 2D graphics
*/
public class PrintTest
{
public static void main(String[] args)
{
JFrame frame = new PrintTestFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
/**
This frame shows a panel with 2D graphics and buttons
to print the graphics and to set up the page format.
*/
class PrintTestFrame extends JFrame
{
public PrintTestFrame()
{
setTitle("PrintTest");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
canvas = new PrintPanel();
add(canvas, BorderLayout.CENTER);
attributes = new HashPrintRequestAttributeSet();
JPanel buttonPanel = new JPanel();
JButton printButton = new JButton("Print");
buttonPanel.add(printButton);
printButton.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
try
{
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(canvas);
if (job.printDialog(attributes))
job.print(attributes);
}
catch (PrinterException e)
{
JOptionPane.showMessageDialog(PrintTestFrame.this, e);
}
}
});
JButton pageSetupButton = new JButton("Page setup");
buttonPanel.add(pageSetupButton);
pageSetupButton.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
PrinterJob job = PrinterJob.getPrinterJob();
Ïà¹ØÎĵµ£º
javaÖеÄʼþ»úÖÆµÄ²ÎÓëÕßÓÐ3ÖÖ½ÇÉ«£º
1.event object£ºÊ¼þ״̬¶ÔÏó£¬ÓÃÓÚlistenerµÄÏàÓ¦µÄ·½·¨Ö®ÖУ¬×÷Ϊ²ÎÊý£¬Ò»°ã´æÔÚÓëlisternerµÄ·½·¨Ö®ÖÐ
2.event source£º¾ßÌåµÄʼþÔ´£¬±ÈÈç˵£¬Äãµã»÷Ò»¸öbutton£¬ÄÇôbutton¾ÍÊÇevent source£¬ÒªÏëʹbutton¶ÔijЩʼþ½øÐÐÏìÓ¦£¬Äã¾ÍÐèҪע²áÌØ¶¨µÄlistener¡£
3.event listener ......
instanceofÊÇJavaµÄÒ»¸ö¶þÔª²Ù×÷·û£¬ºÍ==£¬>£¬<ÊÇͬһÀà¶«¶«¡£ÓÉÓÚËüÊÇÓÉ×Öĸ×é³ÉµÄ£¬ËùÒÔÒ²ÊÇJavaµÄ±£Áô¹Ø¼ü×Ö¡£ËüµÄ×÷ÓÃÊDzâÊÔËü×ó±ßµÄ¶ÔÏóÊÇ·ñÊÇËüÓұߵÄÀàµÄʵÀý£¬·µ»ØbooleanÀàÐ͵ÄÊý¾Ý¡£¾Ù¸öÀý×Ó£º
¡¡¡¡String s = "I AM an Object!";
¡¡¡¡boolean isObject = s instanceof Object;
¡¡¡¡ÎÒÃÇÉùÃ÷ÁËÒ»¸öStrin ......
Òì³£
Òì³£´æÔÚµÄÄ¿µÄ
¿´Ò»ÏÂCÓïÑԵijö´í´¦Àí·½Ê½
int f() {
f1();
f2():
f3();
}//Èç¹ûÔÚÿ¸öº¯Êýºó¶¼Ôö¼Ó³ö´íµÄÅжÏ(Èç¹ûÊÇÕý³£Âß¼¿ÉÒÔ×ß²»Í¬µÄ·ÖÖ§)²¢ÊÍ·Å×ÊÔ´£¬ÄÇÕâ¸öº¯ÊýÄÚ»áÓÐÌ«¶àÓëÖ÷¸ÉÎÞ¹ØÓ°ÏìÇåÎúÔĶÁµÄ´úÂë´æÔÚ£¬¶øÇÒ¹ý¶àreturnÓÐʱ»áʹµÃ×ÊÔ´µ ......
serialVersionUID ÓÃÀ´±íÃ÷ÀàµÄ²»Í¬°æ±¾¼äµÄ¼æÈÝÐÔ
¡¡¡¡¼òµ¥À´Ëµ£¬JavaµÄÐòÁл¯»úÖÆÊÇͨ¹ýÔÚÔËÐÐʱÅжÏÀàµÄserialVersionUIDÀ´ÑéÖ¤°æ±¾Ò»ÖÂÐԵġ£ÔÚ½øÐз´ÐòÁл¯Ê±£¬JVM»á°Ñ´«À´µÄ×Ö½ÚÁ÷ÖеÄserialVersionUIDÓë±¾µØÏàӦʵÌ壨ÀࣩµÄserialVersionUID½øÐбȽϣ¬Èç¹ûÏàͬ¾ÍÈÏΪÊÇÒ»Öµģ¬¿ÉÒÔ½øÐз´ÐòÁл¯£¬·ñÔò¾Í»á³öÏÖÐòÁÐ ......
µÚ1Õ ѡÔñÌâ
1.1 ÏÂÁÐÓï¾äÄÄÒ»¸öÕýÈ·£¨£©
¡¡¡¡A£® Java³ÌÐò¾±àÒëºó»á²úÉúmachine code
¡¡¡¡B£®Java³ÌÐò¾±àÒëºó»á²úÉúbyte code
¡¡¡¡C£®Java³ÌÐò¾±àÒëºó»á²úÉúDLL
¡¡¡¡D£®ÒÔÉ϶¼²»ÕýÈ·
1.2 ÌṩJava´æÈ¡Êý¾Ý¿âÄÜÁ¦µÄ°üÊÇ£¨£©
¡¡¡¡A£®java.sql
¡¡¡¡B£®java.awt
¡¡¡¡C£®java ......