Jump to content
xisto Community
Sign in to follow this  
mongos

Where Can I Learn To Make Java Applets ? Where can I learn to make java applets ?

Recommended Posts

Probably the best way to do it is to take a class or to learn from a sibling or parent A book would be useful, too.
After that, it'd be good to try online tutorials.
I really have found learning Java to be very difficult. My best luck has come from looking at examples from Freewarejava.com that has something to do with what I want to do.

Share this post


Link to post
Share on other sites

How much do you understand about Java? basicly an applet is the same as a regular java program except for some key things

The general form of an applet is

import java.awt.*;import java.applet.Applet;public class Example extends Applet {          public void paint(Graphics page)     {          //code for creating graphics go here     }     //any additional methods or code go here}

You will also need a HTML launch page to launch the applet in a web browser. here is a simple one:
<APPLET CODE="Example.class" WIDTH=500 HEIGHT=500></APPLET>"WIDTH=500" sets the width of the functioning area for the applet"HEIGHT=500" does the same thing for the height"APPLET CODE="Example.class" tells the brower to use the code in the class file Example.class to run the applet once it is open

to create this HTML just open notepad write that line of code as it applies to your applet and save it as a .html file this needs to be in the same folder as the class file.

heres some example code of an applet I wrote for a class
// Program: Bouncing Ball// Author:  Michael Kurelja// Date:    1/31/05// Email:// IDNUM:// File ends with "End-of-File"// This applet draws an animated bouncing ball with uniform speed.// The ball starts at the center of the graphics page and bounces off// the top and bottom.import java.awt.*;import java.applet.Applet;public class BouncingBall extends Applet {[tab][/tab]// Dimensions of Applet:[tab][/tab]public final int width = 500;[tab][/tab]public final int height = 500;[tab][/tab]// Size and speed of ball:[tab][/tab]public final int diameter = 20;[tab][/tab]public final int speed = 5;[tab][/tab]// Milliseconds to pause between frames:[tab][/tab]public final int pause = 20;[tab][/tab]public void paint (Graphics page) [tab][/tab]{  //position1 controls the position of the ball, increment controls the direction:  int position1 = 0, increment = 1;  setBackground(Color.blue);  page.setColor(Color.red);  page.fillOval((width/2)-(diameter/2),(height/2)-(diameter/2),diameter, diameter);  //sets the position1 int to the center of the screen for the height variable:  position1 = (height/2) - (diameter/2);      // Loop forever:  while (true)       {     [tab][/tab] //sets the color of the ball to red: [tab][/tab] page.setColor(Color.red);     [tab][/tab] //moves the ball up or down: [tab][/tab] if (position1 <= (500 - diameter) && position1 > 0)      [tab][/tab] {    if (increment == 1)     {          [tab][/tab] position1 = position1 - speed;   [tab][/tab] page.fillOval((width/2)-(diameter/2), position1, diameter, diameter);    }      else if (increment == 0)     {   [tab][/tab] position1 = position1 + speed;   [tab][/tab] page.fillOval((width/2)-(diameter/2), position1, diameter, diameter);    }               [tab][/tab] }       [tab][/tab] // the following 2 "else if ()" statements switch the direction of the ball: [tab][/tab] else if (position1 <= 0)  [tab][/tab] {             increment = 0;    position1 = 1; [tab][/tab] } [tab][/tab] else if (position1 >= (500-diameter))  [tab][/tab] {    increment = 1;    position1 = (499-diameter); [tab][/tab] }       [tab][/tab] // Pause between frames:       [tab][/tab] try {Thread.sleep(pause);}        [tab][/tab] catch (Exception e) { };       [tab][/tab] //erases the previous ball: [tab][/tab] page.setColor(Color.blue);       [tab][/tab] page.fillOval((width/2)-(diameter/2), position1, diameter, diameter);      }  [tab][/tab]}}// End-of-File

Share this post


Link to post
Share on other sites

Also, if you ahve any specific questions, you can ask at YouLikeJava.tk. But those forums aren't close to being as established as the Java forums at java.sun.com.To get a taste of aplets (open source) try javaboutique.comHOpe you get going with Applets soon.

Share this post


Link to post
Share on other sites

Hi mongos,

I think you already have starded learning Applet. I hope you are enjoying the power of Java.

Before going further, it's important for you to understand something about Java. I think you should already have read about it .... but if not, it's time.

When talking about Java, you will often ear about Java 1 and Java 2. I'm not going in the details. Java 2 introduced the Swing which is a set of classes (API-Application Programming Interface) for gui building. Beforce, java coders used to work with AWT (you should read about all this).

AWT use heavy components (heavy to draw) and Swing came with light weight components. You will often see 'J' before some classes like Applet end JApplet. That's where i wanted to come.

Applet is not longer used. Instead, you will have to use JApplet. So if you are still working with Applet, update your code and read about differences.

One thing is very important also when you use Applet (JApplet). The security side. If you dont "sign" your applet, the browser can block its running.

http://forums.xisto.com/no_longer_exists/

It's so cool to code and most of time we don't take enough time to read before coding.
Read first, design all you wan to do on this cool and so usefull white paper, then start coding.

Good luck with the coffee!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.