1. Trang chủ
  2. » Công Nghệ Thông Tin

Lập trình môn java hay nhất

140 452 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 140
Dung lượng 3,29 MB

Nội dung

Made by HK Java Table of Contents S c v Java JVM( Java Virtual Machine) Đ ng l p .5 Bi n(Variables) Data types 10 Đ E 10 String 11 String 11 StringBuilder and StringBuffer 14 StringTokenizer 15 T khóa static+this+super+final 16 T khóa static: 16 T khóa this 17 T khóa super 22 T khóa final 24 Override and Overload 25 K th a 26 Abstract 28 Tính tr P L p tr ng 28 c tr ng(astract methods) 28 ng(Abstract class) 28 Interface 29 Interface gì? 29 T i ph i s d ng? 30 M i quan h k th a 30 X lý ngo i l (Exception Handling) 33 S d ng kh i try catch x lý ngo i l 34 T khóa throw 35 T khóa throws 35 Assertion+Logging 36 Assertion 36 Made by HK Logging 37 S d ng I/O 37 Đ ng(Multithreading) 38 Threads gì? 38 L i ích c ng 38 Multitasking 38 V 39 Cách t o thread 40 T o thread b ng cách s d ng interface Runnable 41 T o thread b ng cách k th a t l p Thread 42 Th t 42 P c join() 43 Đ ng b hóa gi a thread 44 M i quan h gi a thead 47 Hi ng dead lock 49 Daemon threads 51 Garbage Collection 52 P th c finalize () 53 Enumerations, Autoboxing,Static import,Annotations 54 Enumrations 54 Autoboxing 56 Static import 58 Annotations 58 Generics 59 Đ 59 T o class generic method 60 Các ký hi i di n generic 62 Gi i h n ki u d li u 64 Generic Constructors 65 Generic Interfaces 65 M t s h n ch c a Generic 66 Lambda expressions,Inner classes,Proxies 67 Lambda expressions 67 Made by HK Class vô danh(Anonymous Classes) 67 Lambda expressions 68 Inner classes 74 Đ 74 Member Inner Class ? 75 Anonymous Inner Class gì? 76 Local Inner Class gì? 78 Static Nested Class gì? 80 Nested Interface gì? 80 Proxies 84 Collections 84 S d ng Iterator Java 89 Concrete Collections 92 ArrayList 92 ArrayList gì? 94 Vector 99 LinkedList 101 HashSet class 104 TreeSet class 105 Stack and Queues 106 Priority Queues 106 Maps 107 Map Interface 107 HashMap class 108 TreeMap 110 Hashtable class 112 Difference between HashMap and Hashtable 114 B ng tóm t t 115 AWT and Swing 115 AWT(Abstract Windows Toolkit) 116 Container 118 Window 118 Panel 118 Made by HK Frame 118 Swing 119 So sánh AWT SWING 120 Container 121 JFrame gì? 121 JPanel gì? 126 Graphics 127 X lý nh 132 Cách 1: S d ng Toolkit 132 Cách 2: S d ng BufferedImage 133 Cách 3: s d ng ImageIcon 133 X lý s ki n 135 Tài li u tham kh o 140 S c v JavaJava gì?  Java ngơn ng l p trình c à c phát tri n b ààJ àG à ng nghi p “ àM àB à à àO à à i tên thành Java, v i m à Write Once, Run Anywhere  Java ch à nt ààW àM àO“ àL àU  Đ m c a ngôn ng Java:  Object Oriented àH à ng: In Java, everything is an Object Java can be easily extended since it is based on the Object model  Platform Independent Đ c l p n n t ng: Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code This byte code is distributed over the web and interpreted by the Virtual Machine (JVM) on whichever platform it is being run on  Simple àĐ n: Java is designed to be easy to learn If you understand the basic concept of OOP Java, it would be easy to master  Secure: B o m t:With Java's secure feature it enables to develop virus-free, tamper-free systems Authentication techniques are based on public-key encryption  Architecture-neutral: Đ c l p c u trúc:Java compiler generates an architectureneutral object file format, which makes the compiled code executable on many processors, with the presence of Java runtime system Made by HK        Portable: Kh chuy n:Being architecture-neutral and having no implementation dependent aspects of the specification makes Java portable Compiler in Java is written in ANSI C with a clean portability boundary, which is a POSIX subset Robust: M nh m :Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking Multithreaded àĐ ng: With Java's multithreaded feature it is possible to write programs that can perform many tasks simultaneously This design feature allows the developers to construct interactive applications that can run smoothly Interpreted: Thông d ch:Java byte code is translated on the fly to native machine instructions and is not stored anywhere The development process is more rapid and analytical since the linking is an incremental and light-weight process Distributed:Phân tán: Java is designed for the distributed environment of the internet Dynamic: Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time High Performance:Hi u su t cao: With the use of Just-In-Time compilers, Java enables high performance JVM( Java Virtual Machine)  Đ K àJ c biên d ch, à c biên d ch vào n n t ng máy c th , thay à à àB cl pn nt àB à c phân ph i thông qua W à c thông d ch b i Java Virtual Machine (JVM) b t k n n t ng y ng l p   Đ ng là: th c th th c t à nh b à  Behavior:Hành vi  State: Tr ng thái  Identity: nh n di n L p: khuôn m u(template) ho c b n thi t k có chung thu c tính c tính: ct ob à ng: Made by HK Bi n(Variables) Các t tên bi n :All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_)  Local Variable:  C à  C à à  C à  C báo à  Các à  K à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à  Instance variables: Thu c tính:  C à à    K à C à C à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à à  C   C à à à à à à C à à à à à à àT à à à à à à à à à à à C à à à à àV à à à à à à à àC à à à à constructor  à à à à à à àB à à Made by HK à à à à à à àT à à à à à à à à à à à à ObjectReference.VariableName  Class/Static variable:  C à à à à à à à à à à à   C “ à à  C C à à à à à à  C à à  T à à à C à  K N à à à à à à à G à à Boo à à à à à  à à à à à à à àC à à à C  à à à à à à à à à à à à à à à à à à à à à  à à à à à à à à à à à à àN à à à à à à àT à à à à à à à à à à à à à à à à à àC à à à àV à à à àC à à à à à à à à à à à à à à à à à à à à à Name.VariableName à à à à à à Made by HK  P àI àV àC àStatic variable:  Instance variables: These variables belong to the instance of a class, thus an object And every instance of that class (object) has it's own copy of that variable Changes made to the variable don't reflect in other instances of that class public class Product { public int Barcode; }  Class variables: These are also known as static member variables and there's only one copy of that variable that is shared with all instances of that class If changes are made to that variable, all other instances will see the effect of the changes public class Product { public static int Barcode; } Full example: // INSTANCE VARIABLE public class Main { public static void main(String[] args) { Product prod1 = new Product(); prod1.Barcode = 123456; Product prod2 = new Product(); prod2.Barcode = 987654; System.out.println(prod1.Barcode); System.out.println(prod2.Barcode); } } public class Product { public int Barcode; } The output will be: 123456 987654 Now, change the instance variable to a class variable by making it static: //CLASS VARIABLE public class Main { public static void main(String[] args) { Product prod1 = new Product(); prod1.setBarcode(123456); Made by HK Product prod2 = new Product(); prod2.setBarcode(987654); System.out.println(prod1.getBarcode()); System.out.println(prod2.getBarcode()); } } public class Product { public static int Barcode; public int getBarcode() { return Barcode; } public void setBarcode(int value){ Barcode = value; } } I used non-static methods to get and set the value of Barcode to be able to call it from the object and not from the class The output will be following: 987654 987654 Made by HK Data types K M K Bit Min byte short 16 int 32 long 0L 64 float 0.0F 32 double 0.0 64 char boolean Max - FFFF 16 False Đ false true (Encapsulation) T Trong class Trong package Trong subpackage Package khác private Có Khơng Khơng Khơng default Có Có Khơng Khơng Protected Có Có Có Khơng public Có Có Có Có Ngồi static , final, volatile,transient à  static: à  final: à à à à à à à à à à àDL à à à à à à à à à à à à à à 10 Made by HK   gets or sets the undecorated property.When the property is set, the frame is displayed without decorations such as a title bar or close button.This method must be called before the frame is displayed int getExtendedState(); void setExtendedState(int state); gets or sets the extended window state.The state is one of Frame.NORMAL Frame.ICONIFIED Frame.MAXIMIZED_HORIZ Frame.MAXIMIZED_VERT Frame.MAXIMIZED_BOTH java.awt.Toolkit   static Toolkit getDefaultToolkit() ; returns the default toolkit Dimension getScreenSize() ; à à à javax.swing.ImageIcon   ImageIcon(String filename); constructs an icon whose image is stored in a file Image getImage(); gets the image of this icon JPanel gì?  JPanel m à ch a thành ph h à JFrame nhiên khơng ph i JFrame)  Trong m t JFrame ch a JPanel, m i JPanel l i có th ch th m chí JPanel khác à à ng ho c 126 Made by HK      import import import import C à àP c kh i t àJP à à:  JPanel(): T o JPanel v i Layout m nh FlowLayout(cách b ng n i ti p nhau)  JPanel(LayoutManager layout): T o JPanel v àL c ch Đ t Layout cho JPanel : L Thi t l p v à c cho JPanel setBound(x,y,width,heigh); Đ t màu n n cho JPanel : B C Đ ng vi n cho JPanel Có nhi u ki ng vi n S d à c B uVí d : à i nh java.awt.*; javax.swing.JButton; javax.swing.JFrame; javax.swing.JPanel; public class TestJPanel extends JFrame { private static final long serialVersionUID = 1L; public static void main(String[] args) { EventQueue.invokeLater(() -> { JFrame frame = new JFrame("JFrame is me"); JPanel jpan = new JPanel(); frame.add(jpan); JButton btnHello = new JButton("Hello"); jpan.add(btnHello); frame.setSize(300, 100); frame.setVisible(true); }); } } Graphics à    c: void paint(Graphics g); void repaint(); void update(Graphics g); 127 Made by HK a Hình h c public abstract void drawString(String str, int x, int y): is used to draw the specified string public void drawRect(int x, int y, int width, int height): draws a rectangle with the specified width and height public abstract void fillRect(int x, int y, int width, int height): is used to fill rectangle with the default color and specified width and height public abstract void drawOval(int x, int y, int width, int height): is used to draw oval with the specified width and height public abstract void fillOval(int x, int y, int width, int height): is used to fill oval with the default color and specified width and height public abstract void drawLine(int x1, int y1, int x2, int y2): is used to draw line between the points(x1, y1) and (x2, y2) public abstract boolean drawImage(Image img, int x, int y, ImageObserver observer): is used draw the specified image public abstract void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle): is used draw a circular or elliptical arc public abstract void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle): is used to fill a circular or elliptical arc public abstract void setColor(Color c): is used to set the graphics current color to the specified color public abstract void setFont(Font font): is used to set the graphics current font to the specified font Ví d : //JPanel import java.awt.Color; import java.awt.Graphics; import javax.swing.JPanel; public class ClassJpanel extends JPanel { private static final long serialVersionUID = 1L; @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.CYAN); g.drawString(" Hello World ", 200, 150); g.setColor(new Color(255, 200, 0)); g.fillOval(240, 180, 80, 60); } } 128 Made by HK //JFrame import javax.swing.JFrame; public class TestGraphics extends JFrame { private static final long serialVersionUID = 1L; public static void main(String[] args) { JFrame fr = new JFrame(); ClassJpanel hix = new ClassJpanel(); fr.setSize(720, 640); fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fr.getContentPane().add(hix); fr.setVisible(true); } } b B ng màu No Color constant public final static Color RED public final static Color GREEN public final static Color BLUE public final static Color ORANGE public final static Color PINK public final static Color CYAN public final static Color MAGENTA public final static Color YELLOW public final static Color BLACK 10 public final static Color WHITE 11 public final static Color GRAY 12 public final static Color LIGHT_GRAY 13 public final static Color DARK_GRAY c Font Method or constant public Font getFont() public void setFont( Font f ) RGB value 255,0,0 0,255,0 0,0,255 255,200,0 255,175,175 0,255,255 255,0,255 255,255,0 0,0,0 255,255,255 128,128,128 192,192,192 64,64,64 Description Returns a Font object reference representing the current font Sets the current font to the font, style and size specified by the Font object reference f  Font(String tên font,int ki u,int c ch ); Có ki u:  Font.BOLD : ki u ch m  Font.ITALIC :ki u ch nghiêng 129 Made by HK  Font.PLAIN : ki u ch ng  (Font.BOLD|Font.ITALIC) : ki u ch c C ch c tính theo s m c nghiêng m(1 point=1/72 inch) Ví d : import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import javax.swing.JPanel; public class ClassJpanel extends JPanel { private static final long serialVersionUID = 1L; @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.CYAN); g.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 20)); g.drawString(" Hello World ", 200, 150); g.setColor(Color.GREEN); g.setFont(new Font("SansSerif", Font.BOLD | Font.ITALIC, 20)); g.drawString("This is Font SansSerif", 300, 300); g.setColor(new Color(255, 200, 0)); g.fillOval(240, 180, 80, 60); } } FontMetrics L à à c c a ký t khác thu c lo i font khác Xác à c bao g m chi à à à àĐ u r t c n thi t ký t à u chi m m à c riêng B n c à cc n thi t in ký t tránh ký t à  Height: chi u cao c a font  B àD à à à c a ký t (không k ph n th p nh t c a ký t )  Ascent: kho ng cách t à nh c a ký t  Descent: kho ng t à a ký t  Leading: kho ng cách gi a ch 130 Made by HK C à às minh ho vi c s d à T à à à d à lo i font khác L p FontMetric l p tr s à ng c a l àF àF M à à c khác mà l p FontMetrics có à à xem xét chi ti t àP c getFontMetrics() có tham im à FontMetrics fm = g.getFontMetrics (f1); L nh t à ng fm c a l p FontMetrics, v d à l y chi ti t c a font C P P à ng f1 Bây gi , s c getHeight, getAscent(), getDescent(), getLeading() tr v chi ti t c a font c getFont() c a l p FontMetrics tr v Font mà g n v à ng l p FontMetrics c getName() c a l p Font tr v tên Font Ví d : import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import javax.swing.JPanel; public class MetricsJPanel extends JPanel { // display font metrics public void paintComponent(Graphics g) { super.paintComponent(g); // call superclass's paintComponent g.setFont(new Font("SansSerif", Font.BOLD, 12)); FontMetrics metrics = g.getFontMetrics(); g.drawString("Current font: " + g.getFont(), 10, 30); g.drawString("Ascent: " + metrics.getAscent(), 10, 45); g.drawString("Descent: " + metrics.getDescent(), 10, 60); g.drawString("Height: " + metrics.getHeight(), 10, 75); g.drawString("Leading: " + metrics.getLeading(), 10, 90); Font font = new Font("Serif", Font.ITALIC, 14); metrics = g.getFontMetrics(font); g.setFont(font); g.drawString("Current font: " + font, 10, 120); g.drawString("Ascent: " + metrics.getAscent(), 10, 135); g.drawString("Descent: " + metrics.getDescent(), 10, 150); g.drawString("Height: " + metrics.getHeight(), 10, 165); g.drawString("Leading: " + metrics.getLeading(), 10, 180); } } import javax.swing.JFrame; public class Metrics { public static void main(String[] args) { // create frame for MetricsJPanel 11 JFrame frame = new JFrame("Demonstrating FontMetrics"); 131 Made by HK frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MetricsJPanel metricsJPanel = new MetricsJPanel(); frame.add(metricsJPanel); // add metricsJPanel to frame frame.setSize(510, 240); // set frame size frame.setVisible(true); // display frame } }  K t qu : X lý nh Cách 1: S d ng Toolkit import import import import java.awt.Canvas; java.awt.Graphics; java.awt.Image; java.awt.Toolkit; import javax.swing.JFrame; public class MyCanvas extends Canvas { public void paint(Graphics g) { Toolkit t=Toolkit.getDefaultToolkit(); Image i=t.getImage("p3.gif"); g.drawImage(i, 120,100,this); } public static void main(String[] args) { MyCanvas m=new MyCanvas(); JFrame f=new JFrame(); f.add(m); f.setSize(400,400); f.setVisible(true); } 132 Made by HK } Cách 2: S d ng BufferedImage BufferedImage img = null; try { img = ImageIO.read(new File("strawberry.jpg")); } catch (IOException e) { } Cách 3: s d ng ImageIcon Image image = new ImageIcon("Folder path").getImage(); Ví d : import import import import import import java.awt.Graphics; java.awt.Image; java.awt.Toolkit; java.awt.image.BufferedImage; java.io.File; java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JPanel; public class ClassJpanel extends JPanel { private static final long serialVersionUID = 1L; @Override public void paintComponent(Graphics g) { super.paintComponent(g); // Cách 1: Toolkit tk = Toolkit.getDefaultToolkit(); Image image1 = tk.getImage("res/p3.gif"); g.drawImage(image1, 200, 180, this); // Cách 2: Image image2 = new ImageIcon("res/p3.gif").getImage(); g.drawImage(image2, 200, 250, this); // Cách 3: try { BufferedImage image3; image3 = ImageIO.read(new File("res/p3.gif")); g.drawImage(image3, 200, 320, this); } catch (IOException e) { e.printStackTrace(); } } } import javax.swing.JFrame; 133 Made by HK public class TestGraphics extends JFrame { private static final long serialVersionUID = 1L; public static void main(String[] args) { JFrame fr = new JFrame(); ClassJpanel hix = new ClassJpanel(); fr.setSize(720, 640); fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fr.getContentPane().add(hix); fr.setVisible(true); //fr.setResizable(false); } } K t qu : 134 Made by HK X lý s ki n       M t s ki ng x y có s i giao di à h a Ví d à i dùng click chu t vào m t button, click vào m t m à à à v y m t s ki n s c kích ho t Các thành ph h a (components) t o s ki à cg à n s ki (event source) Các ngu n s ki n s g à à ng s ki n (event object) Các s ki c x lý b i m t s ki n l à à c gán cho ngu n s ki n Các thành ph n khác c a GUI s có event listener khác Xây d ng GUI k t n i (còn g à à i listeners Listener s th c thi (implements) interface thích h p v i t ng lo i s ki n Th c hi n l nh (trong x lý s ki n) phù h p v i ngu n s ki n Event Handling Summary: Interface Methods ActionListener public void actionPerformed(ActionEvent e) { } AdjustmentListener public void adjustmentValueChanged(Adjust mentEvent e) { } ItemListener Parameter/Accessors ActionEvent:  getActionCommand();  getModifiers(); AdjustmentEvent:  getAdjustable();  getAdjustmentType();  getValue(); public void ItemEvent: itemStateChanged(ItemEvent e)  getItem(); { }  getItemSelectable(); Events Generated By AbstractButton JComboBox JTextField Timer Jscrollbar AbstractButton JComboBox 135 Made by HK FocusListener KeyListener  getStateChange(); public void FocusEvent: focusGained(FocusEvent e) { }  isTemporary(); public void focusLost(FocusEvent e) { } public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } Component KeyEvent:  getKeyChar();  getKeyCode();  getKeyModifiersText(int modifiers);  getKeyText(int keyCode);  isActionKey(); public void MouseEvent: mouseClicked(MouseEvent e) {}  getClickCount(); public void  getX(); mouseEntered(MouseEvent e) {}  getY(); public void mouseExited(MouseEvent e) {}  getPoint(); public void  translatePoint(int x, int y); Component MouseMotionListener public void mouseDragged(MouseEvent e) {} public void mouseMoved(MouseEvent e) {} MouseEvent Component MouseWheelListener public void mouseWheelMoved(MouseWheelEve nt e) { } Component WindowListener public void windowActivated(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowIconified(WindowEvent e){} public void windowOpened(WindowEvent e) {} MouseWheelEvent:  getWheelRotation();  getScrollAmount(); WindowEvent:  getWindow(); MouseListener Component mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e){} Window 136 Made by HK WindowFocusListener WindowStateListener  Đ public void windowGainedFocus(WindowEvent e) {} public void windowLostFocus(WindowEvent e) {} public void windowStateChanged(WindowEven t e) {} WindowEvent:  getOppositeWindow(); Window WindowEvent:  getOldState();  getNewState(); Window à s d ng s ki n: add_tên s ki n Ví d :     addActionListener(this); addItemListener(this); addMouseListener(this); addKeyListener(this); Java Event Handling Code We can put the event handling code into one of the following places:    Within class Other class Anonymous class Ví d 1: Java event handling by implementing ActionListener import import import import java.awt.Button; java.awt.TextField; java.awt.event.ActionEvent; java.awt.event.ActionListener; import javax.swing.JFrame; class AEvent extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; TextField tf; AEvent() { // create components tf = new TextField(); tf.setBounds(60, 50, 170, 20); Button b = new Button("click me"); b.setBounds(100, 120, 80, 30); // register listener 137 Made by HK b.addActionListener(this);// passing current instance // add components and set size, layout and visibility add(b); add(tf); setSize(300, 300); setLayout(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public void actionPerformed(ActionEvent e) { tf.setText("Welcome"); } public static void main(String args[]) { new AEvent(); } } K t qu : Ví d 2: Java event handling by outer class import java.awt.Button; import java.awt.TextField; import javax.swing.JFrame; class AEvent2 extends JFrame { private static final long serialVersionUID = 1L; 138 Made by HK TextField tf; AEvent2() { // create components tf = new TextField(); tf.setBounds(60, 50, 170, 20); Button b = new Button("click me"); b.setBounds(100, 120, 80, 30); // register listener Outer o = new Outer(this); b.addActionListener(o);// passing outer class instance // add components and set size, layout and visibility add(b); add(tf); setSize(300, 300); setLayout(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public static void main(String args[]) { new AEvent2(); } } import java.awt.event.ActionEvent; import java.awt.event.ActionListener; class Outer implements ActionListener { AEvent2 obj; Outer(AEvent2 obj) { this.obj = obj; } public void actionPerformed(ActionEvent e) { obj.tf.setText("welcome"); } } Ví d 3: Java event handling by anonymous class import import import import java.awt.Button; java.awt.TextField; java.awt.event.ActionEvent; java.awt.event.ActionListener; import javax.swing.JFrame; class AEvent3 extends JFrame { private static final long serialVersionUID = 1L; TextField tf; AEvent3() { tf = new TextField(); 139 Made by HK tf.setBounds(60, 50, 170, 20); Button b = new Button("click me"); b.setBounds(50, 120, 80, 30); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tf.setText("hello"); } }); add(b); add(tf); setSize(300, 300); setLayout(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public static void main(String args[]) { new AEvent3(); } } Tài li u tham kh o G àĐ i h c FPT Cay S Horstmann_Core Java_Volume I Fundamentals Tenth Edition http://www.javatpoint.com/java-tutorial http://vietjack.com/java/hoc_java_co_ban_nang_cao.jsp M t s ngu n khác 140 ... 140 S c v Java  Java gì?  Java ngơn ng l p trình c à c phát tri n b ààJ àG à ng nghi p “ àM àB à à àO à à i tên thành Java, v i m à Write Once, Run Anywhere  Java ch à nt ààW àM... compilers, Java enables high performance JVM( Java Virtual Machine)  Đ K àJ c biên d ch, à c biên d ch vào n n t ng máy c th , thay à à àB cl pn nt àB à c phân ph i thông qua W à c thông d ch b i Java. .. being run on  Simple àĐ n: Java is designed to be easy to learn If you understand the basic concept of OOP Java, it would be easy to master  Secure: B o m t:With Java' s secure feature it enables

Ngày đăng: 12/12/2017, 19:50

TỪ KHÓA LIÊN QUAN