I cant export my applet into a runnable jar file
Code java:
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
public class StartingPoints extends Applet implements Runnable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Image i;
private Graphics doubleG;
Ball b, b2, b3, b4;
@Override
public void init() {
setSize(800, 600);
setBackground(Color.black);
}
@Override
public void start() {
b4 = new Ball(Color.RED);
b3 = new Ball(Color.BLUE);
b = new Ball();
b2 = new Ball(250, 250);
Thread thread = new Thread(this);
thread.start();
}
@Override
public void run() {
// TODO Auto-generated method stub
// thread information
while (true) {
b4.update(this);
b3.update(this);
b.update(this);
b2.update(this);
repaint();
try {
Thread.sleep(17);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@Override
public void stop() {
}
@Override
public void destroy() {
}
@Override
public void update(Graphics g) {
if (i == null) {
i = createImage(this.getSize().width, this.getSize().height);
doubleG = i.getGraphics();
}
doubleG.setColor(getBackground());
doubleG.fillRect(0, 0, this.getSize().width, this.getSize().height);
doubleG.setColor(getForeground());
paint(doubleG);
g.drawImage(i, 0, 0, this);
}
@Override
public void paint(Graphics g) {
b.paint(g);
b2.paint(g);
b3.paint(g);
b4.paint(g);
}
}
Re: I cant export my applet into a runnable jar file
How are you trying to execute the Applet? They normally execute in a browser within an html page.
Re: I cant export my applet into a runnable jar file
I wanna have an exe file on desktop and run it :)
Re: I cant export my applet into a runnable jar file
Applets run in a browser. If you want a desktop app, rewrite the code to not require a browser.
I don't know anything about creating an exe file.
Re: I cant export my applet into a runnable jar file
I fyou want create Desktop application you should use JFrame and here is the code how you can run it on web browser
<html>
<body>
<applet code="nameofclassfile.class" width="whateveryouwant" height="whateveryouwant">
</applet>
</body>
</html>
and save as whaterveryouwant.html
--- Update ---
I kinda fixed it, but if you wanted more balls in there i didn't add them but i added moving
heres the link for download:
https://dl.dropbox.com/u/95019436/StartingPoint.java