Results 1 to 5 of 5

Thread: How to Make Applets in Java?

  1. #1
    Join Date
    Aug 2006
    Posts
    121

    How to Make Applets in Java?

    Hi friends,
    I am new to the applets. Before that I have done some basic programming in Java. But I don't know anything about the Applets.!! So i thought that there will be some guys interested in helping me.!! So please tell me how to Make Applets in Java? If you would provide the coding, that would be much better for me to understand.!!
    Whats my name again? I spend so much time looking at code i fogot my own name ahhh!

  2. #2
    Join Date
    Mar 2008
    Posts
    672

    Re: How to Make Applets in Java?

    You will have to follow the steps for testing the applet which are given as below :
    1. Open NotePad and copy and paste the code in the code section.
    2. Click file, and then click save as, and save it in your java folder but name the code "test.java" .
    3. Exit the window. After exiting, click start, run, then type in cmd in the box and press OK.
    4. Type cd C:\jdk6\bin and press enter.
    5. Type javac then C:\java\test.java and press enter.
    6. Now copy and paste the launcher into NotePad and Click file, and then click save as, and save it in your java folder but name the launcher. "test.htm"
    7. Now go to the java folder you made and launch the test.htm file.

  3. #3
    Join Date
    Nov 2008
    Posts
    996

    Re: How to Make Applets in Java?

    You should be knowing that the JApplet is a class that enables applets to use Swing components. JApplet is a subclass of java.applet.Applet. The information provided in that trail applies to Swing applets. Any applet that contains Swing components must be implemented with a subclass of JApplet. Because JApplet is a top-level Swing container, each Swing applet has a root pane. You can add menu bar using the applet.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to Make Applets in Java?

    There are some main methods in init, start, stop, and destroy. Below is an example for that :
    Code:
    public void init() {
        try {
            javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    createGUI();
                }
            });
        } catch (Exception e) {
            System.err.println("createGUI didn't successfully complete");
        }
    }
    
    private void createGUI() {
        JLabel label = new JLabel(
                           "You are successfully running a Swing applet!");
        label.setHorizontalAlignment(JLabel.CENTER);
        label.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.black));
        getContentPane().add(label, BorderLayout.CENTER);
    }

  5. #5
    Join Date
    Jul 2006
    Posts
    442

    Re: How to Make Applets in Java?

    I have given you another example of the applet. Just have a look at the example :
    Code:
    public void init() {
        ...
        imgs = new ImageIcon[nimgs];
        (new SwingWorker() {
            public ImageIcon[] doInBackground() {
                //Images are numbered 1 to nimgs,
                //but fill array from 0 to nimgs-1.
                for (int i = 0; i < nimgs; i++) {
                    imgs[i] = loadImage(i+1);
                }
                return imgs;
            }
            ...
        }).execute();
    
    }
    "When they give you ruled paper, write the other way..." J.R.J.

Similar Threads

  1. Logitech G19 Applets are missing
    By Micro-Dona in forum Hardware Peripherals
    Replies: 3
    Last Post: 22-05-2012, 03:38 PM
  2. Applets V/s Swing in JAVA
    By "Dritan" in forum Software Development
    Replies: 3
    Last Post: 14-12-2010, 09:04 AM
  3. How to use applets?
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 25-02-2010, 02:12 AM
  4. How to Communicate with other Applets?
    By PsYcHo 1 in forum Software Development
    Replies: 4
    Last Post: 18-02-2010, 04:17 AM
  5. How to Develop a Draggable Applets?
    By N I C K in forum Software Development
    Replies: 5
    Last Post: 18-02-2010, 03:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,064,647.89313 seconds with 17 queries