<title>Planetary system</title>
<p> Applet</p>
<p align=center> 
<applet code="applet.class"

if i run my applet from eclipse, then it works fine.
in command line i wrote jar cvf0 planetary.jar *, jar file was created
and i uploaded it and i have index.html, applet.class and planetary.jar file
the applet just doesn't run. i've googled much about it, made it very simple, without codebase etc. also it doesn't work on my pc i get my applet as transparent and doesn't work. why is it so?

Where are all the files (jar, class, html) when you try to open the html page in a browser? Is the planetary class in a package?
What messages are in the browser's Java console? Please copy and paste them here.

hey, got it to work, eclipse ran it still as application, there had i a problem with correct extending from JFrame to JApplet.
But now there is another problem, i got

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.NumberFormat;

import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;

import javax.swing.JPanel;

import planetary.PSController;

 * Userinterface class / layer
 * @author Priit Reiser
 * lihtsustused A. Torim
public class UserInterface extends JApplet [B]implements Runnable[/B]{

        [B]Thread t = null;
	boolean threadSuspended;[/B]

	private static final int SLEEP_BETWEEN_TICKS = 50;

	private static final String LBL_TITLE_INFO_PANEL = "Time";
	private static final String LBL_TITLE_PLANNED_SHIP_PANEL = "Planned SpaceShip";

	private static final String LBL_SINGLE_TICK = "Tick";

	private static final String LBL_STOP_AUTO_TICK = "Stop auto tick";

	private static final String LBL_START_AUTO_TICK = "Start auto tick";
	private static final String LBL_LAUNCH_SHIP = "Launch Spaceship";
	private static final String LBL_LAUNCH_PLANNED_SHIP = "Launch Planned Spaceship";
	private static final String LBL_LOG = "Log";
	private static final long serialVersionUID = 1L;

	private final PSController controller = new PSController(); 
	private double cx=0;
	private double cy=0;
	private double zoom=0;
	private double planetWidth=0;

	private static boolean tick = true;
	private static boolean auto = false;

	 * wait between ticks.
	private void busy() {
		try {
		} catch (InterruptedException e) {
	private JPanel planetsPanel = new JPanel(new FlowLayout()) {

		private static final long serialVersionUID = -4598415608421582065L;

		public void paint(Graphics g) {			
	private JPanel buttonsPanel = new JPanel();
	private JPanel timeBtnPanel = new JPanel();
	private JPanel flightPlannedShipPanel = new JPanel();
	private JPanel logPanel = new JPanel(new FlowLayout());
	private JButton btnTick = new JButton(LBL_SINGLE_TICK);
	private JButton btnAuto = new JButton(LBL_START_AUTO_TICK);
	private JButton btnShip = new JButton(LBL_LAUNCH_SHIP);
	private JButton btnFLShip = new JButton(LBL_LAUNCH_PLANNED_SHIP);
	 * different commands 
	private final static int DIFF_COMMANDS = 3;
	 * [0] - wait(tick)
	 * [1] - direction changing
	 * [2] - speed changing
	JFormattedTextField ftf[] = new JFormattedTextField[DIFF_COMMANDS];
	JButton btn_flight[] = new JButton[DIFF_COMMANDS];
	Label des[] = new Label[DIFF_COMMANDS];
	des[0] = new Label("Wait(tick):");
	ftf[0] = new JFormattedTextField(NumberFormat.getInstance());
	ftf[0].setToolTipText("Enter number how many ticks to wait before executing next command");
	btn_flight[0] = new JButton("Wait!");
	des[1] = new Label("Direction:");
	ftf[1] = new JFormattedTextField(/*NumberFormat.getInstance()*/);
	ftf[1].setToolTipText("Enter number how much to change angle of the ship");
	btn_flight[1] = new JButton("Change direction!");
	des[2] = new Label("Speed:");
	ftf[2] = new JFormattedTextField(/*NumberFormat.getInstance()*/);
	ftf[2].setToolTipText("Enter number how much to change speed of the ship");
	btn_flight[2] = new JButton("Change Speed!");
	public UserInterface() {
	public void init() {
		// 1. create new planetary system
		//this.controller.launchSpaceShip(3, 0.5, 0.5);
		this.planetWidth = 3; = 350.0; = 350.0;
		this.zoom = 7.0;

		for (int i = 0; i < ftf.length; i++) {
			this.flightPlannedShipPanel.add(new JSeparator(SwingConstants.VERTICAL));

		this.btnTick.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
		this.btnAuto.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
		this.btnShip.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
		this.btnFLShip.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
		// oota(tick)
		btn_flight[0].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try {
				} catch (NumberFormatException e) {
					exceptionMsg("wrong entered command");
		// suund
		btn_flight[1].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try {
				} catch (NumberFormatException e) {
					exceptionMsg("wrong entered command");
		// kiirus
		btn_flight[2].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try {
				} catch (NumberFormatException e) {
					exceptionMsg("wrong entered command");
		buttonsPanel.setLayout(new BorderLayout());
		buttonsPanel.add(timeBtnPanel, BorderLayout.NORTH);
		buttonsPanel.add(flightPlannedShipPanel, BorderLayout.CENTER);
		setLayout(new BorderLayout());
		JTextArea log = new JTextArea("here will be log later", 38, 15);
		JScrollPane scrollPane = new JScrollPane(log);
		logPanel.setMinimumSize(new Dimension(100, 20));
		logPanel.setPreferredSize(new Dimension(200, 20));
		add(planetsPanel, BorderLayout.CENTER);
		add(logPanel, BorderLayout.EAST);

		[B]new Thread(new Runnable() {
	    	public void run() {

	    		while(true) {
	    			if(tick) {
	    				// *** 1. calculate objects new coordinates ***
		    			// *** 2. draw changed position on UI***
		    			// *** 3. if we are in manual mode, then stop moving ***
						if(!auto) {
							tick = false;
	public void exceptionMsg(String s) {
		JOptionPane.showMessageDialog(null, s, "Error", 

	public void handleBtnClickSingleTick() {
		auto = false;
		tick = true;
		if (tick) this.btnAuto.setText(LBL_START_AUTO_TICK);
	public void handleBtnClickAutoTick() {
		if(auto) {
			auto = false;
			tick = true;
		} else {
			auto = true;
			tick = true;
	public void handleBtnLaunchSpaceShip() {
		if (auto) this.controller.launchSpaceShip(3, -0.5, -0.5);
	public void handleBtnLaunchFPSpaceShip() {
		if (auto) this.controller.launchFPSpaceShip(3, 0.5, 0.5);
	public void drawPlanets(final Graphics g) {			
		for (int i=0; i<controller.getPlanetarySystem().size(); i++ ){
			drawPlanet(g, i);

	public void drawPlanet(final Graphics g, int planetID) {		
		double x = controller.getPlanetarySystem().getElement(planetID).getx();
		double y = controller.getPlanetarySystem().getElement(planetID).gety();
		double[] newCoordinates = convCoords(x, y);
		g.drawOval((int)newCoordinates[0] ,(int)newCoordinates[1], (int)planetWidth, (int)planetWidth);		

	 * Simulation of coordinates convertion for UI suitable shapes
        Depends of attributes: 
        cx, cy - show centerpoint
        zoom - zoom
        planet_width - planet width
        Outputs 4 coordinates for drawing oval
	public double[] convCoords(double x, double y) {
		double x0 = ( + x * this.zoom); 
		double y0 = ( + y * this.zoom);
		double x1 = x0 + this.planetWidth;
		double y1 = y0 + this.planetWidth;
		return new double[] {
			x0, y0, x1, y1

[B]public void run() {
    		while(true) {
    			if(tick) {
    				// *** 1. calculate objects new coordinates ***
	    			// *** 2. draw changed position on UI***
	    			// *** 3. if we are in manual mode, then stop moving ***
					if(!auto) {
						tick = false;
	// Executed when the applet is destroyed.
	public void destroy() {

	   // Executed after the applet is created; and also whenever
	   // the browser returns to the page containing the applet.
	   public void start() {
	      System.out.println("start(): begin");
	      if ( t == null ) {
	         System.out.println("start(): creating thread");
	         t = new Thread( this );
	         System.out.println("start(): starting thread");
	         threadSuspended = false;
	      else {
	         if ( threadSuspended ) {
	            threadSuspended = false;
	            System.out.println("start(): notifying thread");
	            synchronized( this ) {
	      System.out.println("start(): end");

	   // Executed whenever the browser leaves the page containing the applet.
	   public void stop() {
	      System.out.println("stop(): begin");
	      threadSuspended = true;

	public static void main(String args[]) {
		/*UserInterface content = new UserInterface();
		new UserInterface().show();


If you click tick button, then everything will be moved once (a single tick). When i had it as application (the red code was active without green code) clicking on "start autotick" began moving elements without stoping, but now this button acts as single tick when i'm using the green code. took it from here
and always makes a single move...

Have you tried debugging you code to see why it is not acting like you want it to?
Add some println()s to show how variables are changing value and where the code execution is going.

got it at last to work. the mistake was in the constructor. i was calling there out init() method, but when i commented out my constructor, then it just started to work.
i think i wont understand all the details soon. can't get it why this init method stopped the runnable, didn't even think about that problem is there. i could call my method from another plain method and another method again from another plain method and it shouldn't change anything..

The browser calls the init() method. Perhaps your calling it and then the browser calling it got it confused.