Thứ Hai, 21 tháng 11, 2011

How to Create a Java Applet in Netbeans



How to Create a Java Applet in Netbeansthumbnail
NetBeans helps you write your Java Code easily

Netbeans is an IDE for Java, PHP and Apache. IDE, which stands for Integrated Development Environment, is basically a fancy way of saying "editor." Using Netbeans, you can write Java code and run Java programs quickly and easily. This is in contrast to running your Java programs from the Terminal and writing them in Notepad, which can become tedious and can be quite complicated. If you do not have Netbeans, you can install it using the link in the Resources section below.

Instructions

    • 1
      In Netbeans, create a new project by going to "File > New Project." In the "Choose Project" window, click "Java Application" and click "Next." Name the project "FirstApplet" and click "Finish."
    • 2
      Under "Source Packages" double-click the "firstapplet" package (with the brown box icon) and click "New > Java Class." Name the class "GreenLines" and click "Finish."
    • 3
      Under the line "package firstapplet;" type the following two lines of Java code:
      import java.applet.*;
      import java.awt.*;
      This imports the Applet and Graphics Java libraries, which you will use in your code.
    • 4
      Between "public class GreenLines" and the "{" type "extends Applet" to tell Java that the GreenLines class is going to be an Applet.
    • 5
      Inside the GreenLines class, initialize the height and width variables for your applet by typing the line:
      int m_height, m_width;
    • 6
      Create the following two methods ("init" and "paint) to have your Java code initialize the Applet with a height, width and background color, then "paint" 10 lines across the screen:
      public void paint(Graphics m) {
      m.setColor(Color.black);
      for (int i = 0; i < 10; ++i) m.drawLine(m_width, m_height, i * m_width / 10, 0);
      }
      public void init() {
      m_width = getSize().width;
      m_height = getSize().height;
      setBackground(Color.green);
      }
    • 7
      Click "Run" from the top menu of Netbeans, then click "Run File." Your Java Applet's window will pop up and you will see 10 lines drawn across the screen.

Thứ Năm, 17 tháng 11, 2011

Thông báo cho buổi học ngày 11/11/2011  (các lớp 11A1, 11A3)


 1. Xem trước bài kiểu mảng (Tr 52 SGK Tin học 11)
 2. Lớp phó truy cập vào địa chỉ:  http://www.mediafire.com/?48sx3px3sjjql85  để tải liệu phiếu học tập
     cho  lớp.

 3. Lớp chuẩn bị phấn và giẻ lau bảng.




Giới Thiệu Chương Trình Tin Học Lớp 11




11