Hi, i would be grateful for a solution or some explaining. My example is that i have a controlled spaceship.
here is userinterface:
3 - planet from which is starts, 0.5 and 0.5 the speed of the ship

public void handleBtnLaunchFPSpaceShip() {
this.controller.launchFPSpaceShip(3, 0.5, 0.5);
    }

my controller class:

public void launchFPSpaceShip (int id, double dx, double dy) {
		PointSimulationElement pls = planetarySystem.getElement(id);
		planetarySystem.append(new PlannedSpaceShip(pls.getx(), pls.gety(), dx, dy));
	}

So when i click in my applet on the button, it launches. But my question is how to appoint to my spaceship speed, direction etc. I mean before i click launch button, i click on the change speed button which multiplies the 0.5 and 0.5 values and then when i click launch, spaceship is launched with new values.
i have done it with command pattern so far.
controller:
cc is my CommandControl class object.

public void executreCommands(PlannedSpaceShip pse) {
        cc.execute();
public void speedFactor(double factor) {
		
		cc.addCommand(new ChangeSpeed(pss, factor));
	}

my ChangeSpeed class

public ChangeSpeed(PlannedSpaceShip pps, double factor) {
        super();
        this.pps = pps;
        this.factor = factor;
    }

    @Override
    public void execute() {
        //this.pps.speedFactor(factor);
        //System.out.println("speed");
        System.out.println(factor);
    }

aaand how to bind then my command control execution with my created spaceship?
here is my userinterface class method which should do the work, bind executeCommands with my launchFPSpaceShip ?

public void handleBtnLaunchFPSpaceShip() {
        this.controller.executeCommands(this.controller.getPSS());
        this.controller.launchFPSpaceShip(3, 0.5, 0.5);
    }

in controller getPSS method:

public PlannedSpaceShip getPSS() {
        return pss;
    }

executing commands should work fine, the numbers are printed out in console when i test them.
here is my UI
[img]http://img185.imageshack.us/img185/3876/planetsystem.jpg[/img] blue circle is the moving planet (red ones are the planets, they are separately)
i've googled it, but don't even know exactly what is the topic for that problem? any hint would be appreciated :)

how to appoint to my spaceship speed, direction etc. I mean before i click launch button,

I assume those properties values are held in variables.
Can you 'appoint'/set their values in the constructor for the spaceship object?

Your scattered comments and pieces of code are hard to follow.
This seems like a logic problem which means we need to see the whole thing to be able to help, unless you have a specific question on how to do something in java.

Sorry, your link to the site with the source show too many different files to download.
Can you make a single zip file to download.

Better would be to create a small program that compiles and executes that demonstrates the problem.

hey, sorry for no long reply

http://www.gasuinfo.org/planetarysystem/index.html
when u click autotick then objects start movin and by clicking launch planeed spaceship, the spaceship flies out. so i want that spaceship to change it's speed but it doesn't do atm
here's my whole code http://www.gasuinfo.org/planetarysystem/src.zip
here are my classes which are linked to my problem

package planetary;

public interface Command {
    public abstract void execute();
}
package planetary;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class CommandControl implements Command {
    
    private List<Command> commands;
       
       public CommandControl() {
           //commands = Collections.synchronizedList(new LinkedList<Command>());
           commands = new LinkedList<Command>();
       }
    
    @Override
    public void execute() {
        
        //((Command) commands).execute();
        //((LinkedList<Command>) commands).removeFirst();
        Iterator<Command> iterator;
        iterator = commands.iterator();
        while (iterator.hasNext()) {
            runSingleCommand();
        }
    }
    
    public void addCommand(Command c) {
           ((LinkedList<Command>) commands).addLast(c);
    }
    
    public void runSingleCommand() {
        ((LinkedList<Command>) commands).getFirst().execute();
        ((LinkedList<Command>) commands).removeFirst();
    }
    
    public int totalCommands() {
        
        return commands.size();
    }
}
package planetary;

import geometry.Point;

public class PlannedSpaceShip extends PointSimulationElement {
    
    double dx, dy;
    CommandControl cc = new CommandControl();
    Point p;
    int ticks = 0;
    
    public PlannedSpaceShip(double x, double y, double dx, double dy) {
        super(x, y);
        this.dx=dx;
        this.dy=dy;
        //cc = new CommandControl();
    }

    @Override
    public void tick() {
        
        this.translate(dx, dy);
        
    }
    
    public void wait(int t) {

    }
    
    public void speedFactor(double factor) {
        this.dx = this.dx * factor;
        this.dy = this.dy * factor;
    }
    
    public void direction(double angle) {
        p = new Point(this.dx, this.dy);
        p.centre_rotate(angle);
        this.dx = p.getx();
        this.dy = p.gety();
    }

}
package commands;

import planetary.Command;
import planetary.PlannedSpaceShip;

public class ChangeSpeed implements Command{
    
    private PlannedSpaceShip pps;
    private double factor;

    public ChangeSpeed(PlannedSpaceShip pps, double factor) {
        super();
        this.pps = pps;
        this.factor = factor;
    }

    @Override
    public void execute() {
        pps.speedFactor(factor);
        System.out.println("speed");
    }

}
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 implements Runnable{

    static Thread t = null;
    boolean threadSuspended;
    
    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;
    private double cy;
    private double zoom;
    private double planetWidth;

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

    /**
     * wait between ticks.
     */
    private static void busy() {
        try {
        t.sleep(SLEEP_BETWEEN_TICKS);                        
        } catch (InterruptedException e) {
        e.printStackTrace();
            }
    }
    
    private JPanel planetsPanel = new JPanel(new FlowLayout()) {

        private static final long serialVersionUID = -4598415608421582065L;

        @Override
        public void paint(Graphics g) {            
            super.paint(g);
            drawPlanets(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() {
        init();
    }*/
    
    public void init() {
        // 1. create new planetary system
        this.controller.makeSolarSystem();
        //this.controller.launchSpaceShip(3, 0.5, 0.5);
        this.planetWidth = 3;
        this.cx = 350.0;
        this.cy = 350.0;
        this.zoom = 7.0;
        
        timeBtnPanel.add(btnTick);
        timeBtnPanel.add(btnAuto);
        timeBtnPanel.add(btnShip);
        timeBtnPanel.add(btnFLShip);
        timeBtnPanel.setBorder(BorderFactory.createTitledBorder(LBL_TITLE_INFO_PANEL));
        logPanel.setBorder(BorderFactory.createTitledBorder(LBL_LOG));

        for (int i = 0; i < ftf.length; i++) {
            this.flightPlannedShipPanel.add(des[i]);
            this.flightPlannedShipPanel.add(ftf[i]);
            ftf[i].setColumns(4);
            this.flightPlannedShipPanel.add(btn_flight[i]);
            this.flightPlannedShipPanel.add(new JSeparator(SwingConstants.VERTICAL));
        }
        
        this.flightPlannedShipPanel.setBorder(BorderFactory.createTitledBorder(LBL_TITLE_PLANNED_SHIP_PANEL));
        
                                
        this.planetsPanel.setBackground(Color.black);

        this.btnTick.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                handleBtnClickSingleTick();                
            }
        });
        
        this.btnAuto.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                handleBtnClickAutoTick();                
            }
        });
        
        this.btnShip.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                handleBtnLaunchSpaceShip();                
            }
        });
        
        this.btnFLShip.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                handleBtnLaunchFPSpaceShip();
            }
        });
        
        // oota(tick)
        btn_flight[0].addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                //handleBtnFPOota
                try {
                    controller.wait(Integer.valueOf(ftf[0].getText()));
                } catch (NumberFormatException e) {
                    exceptionMsg("wrong entered command");
                }
            }
        });
        
        // suund
        btn_flight[1].addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                //handleBtnFPSuund();
                try {
                    controller.direction(Double.valueOf(ftf[1].getText()));
                } catch (NumberFormatException e) {
                    exceptionMsg("wrong entered command");
                }
            }
        });
        
        // kiirus
        btn_flight[2].addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                //handleBtnFPKiirus();
                try {
                    controller.speedFactor(Double.valueOf(ftf[2].getText()));
                } catch (NumberFormatException e) {
                    exceptionMsg("wrong entered command");
                }
            }
        });
        
            
        buttonsPanel.setLayout(new BorderLayout());
        buttonsPanel.add(timeBtnPanel, BorderLayout.NORTH);
        buttonsPanel.add(flightPlannedShipPanel, BorderLayout.CENTER);
        timeBtnPanel.setBackground(Color.GRAY);
        flightPlannedShipPanel.setBackground(Color.GRAY);
        setLayout(new BorderLayout());
        JTextArea log = new JTextArea("here will be log later", 38, 17);
        log.setEditable(false);
        log.setLineWrap(true);
        
        logPanel.setMinimumSize(new Dimension(100, 20));
        logPanel.setPreferredSize(new Dimension(200, 20));
        logPanel.add(new JScrollPane(log));
        add(buttonsPanel,BorderLayout.NORTH);
        add(planetsPanel, BorderLayout.CENTER);
        add(logPanel, BorderLayout.EAST);

        
        //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //setSize(800,800);
        //setVisible(true);
        
        /*new Thread(new Runnable() {
            public void run() {

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

    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;
            this.btnAuto.setText(LBL_START_AUTO_TICK);
        } else {
            auto = true;
            tick = true;
            this.btnAuto.setText(LBL_STOP_AUTO_TICK);
        }                
    }
    
    public void handleBtnLaunchSpaceShip() {
        if (auto) this.controller.launchSpaceShip(3, -0.5, -0.5);
    }
    
    public void handleBtnLaunchFPSpaceShip() {
        this.controller.executeCommands(this.controller.getPSS());
        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.setColor(Color.RED);
        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 = (this.cx + x * this.zoom); 
        double y0 = (this.cy + y * this.zoom);
        double x1 = x0 + this.planetWidth;
        double y1 = y0 + this.planetWidth;
        
        return new double[] {
            x0, y0, x1, y1
        };
    }
    /*public static void main(String args[]) {
        
        //UserInterface content = new UserInterface();
        //setContentPane(content);
        UserInterface ui = new UserInterface();
        ui.show();
    }*/

    public void run() {
        while(true) {
                if(tick) {
                    // *** 1. calculate objects new coordinates ***
                    this.controller.tick();
                    // *** 2. draw changed position on UI***
                    repaint();
                    // *** 3. if we are in manual mode, then stop moving ***
                    if(!auto) {
                        tick = false;
                    }                        
                }    
                busy();                    
            }
    }
    
    // Executed when the applet is destroyed.
    public void destroy() {
          System.out.println("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;
             t.start();
          }
          else {
             if ( threadSuspended ) {
                threadSuspended = false;
                System.out.println("start(): notifying thread");
                synchronized( this ) {
                   notify();
                }
             }
          }
          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;
       }

    

}

just have no idea how to connect the command change speed with my launching spaceship
here is the error i get when i set the speed there and try to launch spaceship:

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at commands.ChangeSpeed.execute(ChangeSpeed.java:19)
at planetary.CommandControl.runSingleCommand(CommandControl.java:33)
at planetary.CommandControl.execute(CommandControl.java:24)
at planetary.PSController.executeCommands(PSController.java:96)
at UserInterface.handleBtnLaunchFPSpaceShip(UserInterface.java:301)
at UserInterface$5.actionPerformed(UserInterface.java:182)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6267)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at commands.ChangeSpeed.execute(ChangeSpeed.java:19)
at planetary.CommandControl.runSingleCommand(CommandControl.java:33)
at planetary.CommandControl.execute(CommandControl.java:24)
at planetary.PSController.executeCommands(PSController.java:96)
at UserInterface.handleBtnLaunchFPSpaceShip(UserInterface.java:301)
at UserInterface$5.actionPerformed(UserInterface.java:182)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6267)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at commands.ChangeSpeed.execute(ChangeSpeed.java:19)
at planetary.CommandControl.runSingleCommand(CommandControl.java:33)
at planetary.CommandControl.execute(CommandControl.java:24)
at planetary.PSController.executeCommands(PSController.java:96)

The NPE occurred at ChangeSpeed line 19. What object at that line is null?
Then check your code to see why it is null and change something to prevent it.

hey, sorry i haven't replied here for long time, remade my command logic, now the speed and direction changing is implemented in their own classes, not the spaceship one.

import ...

public class UserInterface extends JFrame/* implements Runnable*/ {

    static Thread t = null;
    boolean threadSuspended;
    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;
    private double cy;
    private double zoom;
    private double planetWidth;
    private boolean tick = true;
    private boolean auto = false;

    /**
     * wait between ticks.
     */
    private static void busy() {
        try {
            t.sleep(SLEEP_BETWEEN_TICKS);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    private JPanel planetsPanel = new JPanel(new FlowLayout()) {

        private static final long serialVersionUID = -4598415608421582065L;

        @Override
        public void paint(Graphics g) {
            super.paint(g);
            drawPlanets(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() {
    init();
    }*/
    private UserInterface() {
        // 1. create new planetary system
        this.controller.makeSolarSystem();
        this.planetWidth = 3;
        this.cx = 350.0;
        this.cy = 350.0;
        this.zoom = 7.0;

        timeBtnPanel.add(btnTick);
        timeBtnPanel.add(btnAuto);
        timeBtnPanel.add(btnShip);
        timeBtnPanel.add(btnFLShip);
        timeBtnPanel.setBorder(BorderFactory.createTitledBorder(LBL_TITLE_INFO_PANEL));
        logPanel.setBorder(BorderFactory.createTitledBorder(LBL_LOG));

        for (int i = 0; i < ftf.length; i++) {
            this.flightPlannedShipPanel.add(des[i]);
            this.flightPlannedShipPanel.add(ftf[i]);
            ftf[i].setColumns(4);
            this.flightPlannedShipPanel.add(btn_flight[i]);
            this.flightPlannedShipPanel.add(new JSeparator(SwingConstants.VERTICAL));
        }

        this.flightPlannedShipPanel.setBorder(BorderFactory.createTitledBorder(LBL_TITLE_PLANNED_SHIP_PANEL));


        this.planetsPanel.setBackground(Color.black);

        this.btnTick.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                handleBtnClickSingleTick();
            }
        });

        this.btnAuto.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                handleBtnClickAutoTick();
            }
        });

        this.btnShip.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                handleBtnLaunchSpaceShip();
            }
        });

        this.btnFLShip.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                handleBtnLaunchFPSpaceShip();
            }
        });

        // wait(tick)
        btn_flight[0].addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                //handleBtnFPOota
                try {
                    controller.wait(Math.abs(Integer.valueOf(ftf[0].getText())));
                } catch (NumberFormatException e) {
                    exceptionMsg("wrong entered command");
                }
            }
        });

        // direction
        btn_flight[1].addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                //handleBtnFPSuund();
                try {
                    controller.direction(Double.valueOf(ftf[1].getText()));
                } catch (NumberFormatException e) {
                    exceptionMsg("wrong entered command");
                }
            }
        });

        // speed
        btn_flight[2].addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                //handleBtnFPKiirus();
                try {
                    controller.speedFactor(Double.valueOf(ftf[2].getText()));
                } catch (NumberFormatException e) {
                    exceptionMsg("wrong entered command");
                }
            }
        });


        buttonsPanel.setLayout(new BorderLayout());
        buttonsPanel.add(timeBtnPanel, BorderLayout.NORTH);
        buttonsPanel.add(flightPlannedShipPanel, BorderLayout.CENTER);
        timeBtnPanel.setBackground(Color.GRAY);
        flightPlannedShipPanel.setBackground(Color.GRAY);
        setLayout(new BorderLayout());
        JTextArea log = new JTextArea("here will be log later", 38, 17);
        log.setEditable(false);
        log.setLineWrap(true);

        logPanel.setMinimumSize(new Dimension(100, 20));
        logPanel.setPreferredSize(new Dimension(200, 20));
        logPanel.add(new JScrollPane(log));
        add(buttonsPanel, BorderLayout.NORTH);
        add(planetsPanel, BorderLayout.CENTER);
        add(logPanel, BorderLayout.EAST);


        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(800, 800);
        setVisible(true);

        new Thread(new Runnable() {

            public void run() {

                while (true) {

                    if (tick) {


                        // *** 1. calculate objects new coordinates ***
                        controller.tick();

                        // *** 2. draw changed position on UI***
                        repaint();

                        // *** 3. if we are in manual mode, then stop moving ***
                        if (!auto) {
                            tick = false;
                        }
                    }

                    busy();
                }
            }
        }).start();
    }

    public void exceptionMsg(String s) {
        JOptionPane.showMessageDialog(null, s, "Error",
                JOptionPane.ERROR_MESSAGE);
    }

    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;
            this.btnAuto.setText(LBL_START_AUTO_TICK);
        } else {
            auto = true;
            tick = true;
            this.btnAuto.setText(LBL_STOP_AUTO_TICK);
        }
    }

    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);
            //this.controller.executeCommands(this.controller.getSimulationElement());
        }
    }

    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.setColor(Color.RED);
        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 = (this.cx + x * this.zoom);
        double y0 = (this.cy + y * this.zoom);
        double x1 = x0 + this.planetWidth;
        double y1 = y0 + this.planetWidth;

        return new double[]{
                    x0, y0, x1, y1
                };
    }

    public static void main(String args[]) {
        UserInterface userInterface = new UserInterface();
    }

}
package planetary;

import commands.*;

public class PSController {

    // T is for how many atomic tick steps are in Earth year
    private final static double T = 4;
    // Planetarysystem on which is the simulation
    private PlanetarySystem<PointSimulationElement> planetarySystem = null;
    private CommandControl cc;
    private PointSimulationElement pse;
    private PlannedSpaceShip pss;
    private ChangeDirection cd;

    /**	 * Facade method which creates new planetary system
     */
    public void makeSolarSystem() {

        if (getPlanetarySystem() == null) {

            this.planetarySystem = new PlanetarySystem<PointSimulationElement>();
            getPlanetarySystem().append(new Planet(0.39, 0.0, (2.0 * Math.PI) / (87.97 / 365.26) * T));
            getPlanetarySystem().append(new Planet(0.72, 0.0, (2.0 * Math.PI) / (227.7 / 365.26) * T));
            getPlanetarySystem().append(new Planet(1.0, 0.0, (2.0 * Math.PI) / (1.0) * T));
            getPlanetarySystem().append(new Planet(1.52, 0.0, (2.0 * Math.PI) / (686.98 / 365.26) * T));
            getPlanetarySystem().append(new Planet(5.2, 0.0, (2.0 * Math.PI) / (11.86) * T));
            getPlanetarySystem().append(new Planet(9.54, 0.0, (2.0 * Math.PI) / (29.46) * T));
            getPlanetarySystem().append(new Planet(19.18, 0.0, (2.0 * Math.PI) / (84.01) * T));
            getPlanetarySystem().append(new Planet(30.06, 0.0, (2.0 * Math.PI) / (164.81) * T));
            getPlanetarySystem().append(new Planet(39.75, 0.0, (2.0 * Math.PI) / (247.7) * T));

        }
    }

    /**
     * Facade method which moves planetary objects by 1 atomic step
     */
    public synchronized void tick() {

        getPlanetarySystem().tick();
    }

    public PlanetarySystem<PointSimulationElement> getPlanetarySystem() {

        return planetarySystem;
    }

    public void launchSpaceShip(int id, double dx, double dy) {
        PointSimulationElement pl_s = planetarySystem.getElement(id);
        planetarySystem.append(new SpaceShip(pl_s.getx(), pl_s.gety(), dx, dy));
    }

    public void launchFPSpaceShip(int id, double dx, double dy) {
        PointSimulationElement pls = planetarySystem.getElement(id);
        PointSimulationElement pse = new PlannedSpaceShip(pls.getx(), pls.gety(), dx, dy) {
        };
        planetarySystem.append(pse);
    }

    public void wait(int t) {
        //cc.addCommand(new Wait(pss, t));
    }

    public void direction(double angle) { DEBUG POSITION

        pss.getCommands().addCommand(new ChangeDirection(pse, angle)); [B]red is null, angle is the number i choose (the the debug screen)[/B]
        //cc.addCommand(cd.execute()); doesn't let:((
        //cc.addCommand(new ChangeDirection(pse, angle));
    }

    public void speedFactor(double factor) {

        cc.addCommand(new ChangeSpeed(pse, factor));
    }

    public void executeCommands(PointSimulationElement pse) {
        cc.execute();
    }
}
package planetary;

import geometry.Point;

public abstract class PointSimulationElement extends Point implements SimulationElement {

    private double dx;
    private double dy;

    PointSimulationElement(double x, double y) {
        super(x, y);
    }

    public void setDx(double dx) {
        this.dx = dx;
    }

    public void setDy(double dy) {
        this.dy = dy;
    }

    public double getDx() {
        return dx;
    }

    public double getDy() {
        return dy;
    }
}
package planetary;

import ...

public class PlannedSpaceShip extends PointSimulationElement {

    CommandControl cc;
    Point p;
    int ticks = 0;
    PlannedSpaceShip pps;
    ChangeDirection cd;
    ChangeSpeed cs;

    public PlannedSpaceShip(double x, double y, double dx, double dy) {
        super(x, y);
        //cd.setPse(this);
        //cs.setPse(this);
        this.setDx(dx);
        this.setDy(dy);
        cc = new CommandControl();
    }

    @Override
    public void tick() {
        if (ticks > 0) {
            ticks--;

        } else {
            //cc.runSingleCommand();
        }
        this.translate(getDx(), getDy()); // translate anyway

    }
}
package commands;

import ...

public class ChangeSpeed implements Command {

    private PointSimulationElement pse;
    private double factor;
    ChangeSpeed cs;

    public ChangeSpeed(PointSimulationElement pse, double factor) {
        super();
        this.pse = pse;
        this.factor = factor;
    }

    @Override
    public void execute() {
        //new ChangeSpeed(getPse(), getFactor());
        this.getPse().setDx(this.pse.getDx() * factor);
        this.getPse().setDy(this.pse.getDy() * factor);
    }

    /**
     * @return the pse
     */
    public PointSimulationElement getPse() {
        return pse;
    }

    /**
     * @return the factor
     */
    public double getFactor() {
        return factor;
    }

    /**
     * @param pse the pse to set
     */
    public void setPse(PointSimulationElement pse) {
        this.pse = pse;
    }

    /**
     * @param factor the factor to set
     */
    public void setFactor(double factor) {
        this.factor = factor;
    }
}
package commands;

import ...

public class ChangeDirection implements Command {

    Point p;
    private PointSimulationElement pse;
    private double angle;

    public ChangeDirection(PointSimulationElement pse, double angle) {
        super();
        this.pse = pse;
        this.angle = angle;
        
    }

    @Override
    public void execute() {
        //new ChangeDirection(getPse(), getAngle());
        p = new Point(pse.getDx(), pse.getDy());
        p.centre_rotate(angle);
        this.getPse().setDx(p.getx());
        this.getPse().setDy(p.gety());
        //this.pse.changeDirection(this.angle);
    }

    public void setObject(PointSimulationElement pse, double angle) {
        this.pse = pse;
        this.angle = angle;
    }

    /**
     * @return the pse
     */
    public PointSimulationElement getPse() {
        return pse;
    }

    /**
     * @param pse the pse to set
     */
    public void setPse(PointSimulationElement pse) {
        this.pse = pse;
    }

    /**
     * @return the angle
     */
    public double getAngle() {
        return angle;
    }

    /**
     * @param angle the angle to set
     */
    public void setAngle(double angle) {
        this.angle = angle;
    }
}

that is the error i get when i click on my applet change speed. and when debugging my program the pse variable is null and factor/speed is what i typed in the box.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at planetary.PSController.speedFactor(PSController.java:81)
at UserInterface$8.actionPerformed(UserInterface.java:203)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6267)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

there is same problem as i stated in the beginning, that my commands are not binded to my launching spaceship. any solutions how could that be done?

public void launchFPSpaceShip(int id, double dx, double dy) {
        PointSimulationElement pls = planetarySystem.getElement(id);
        PointSimulationElement pse = new PlannedSpaceShip(pls.getx(), pls.gety(), dx, dy) {
        };
        planetarySystem.append(pse);
    }
public void direction(double angle) {

        pss.getCommands().addCommand(new ChangeDirection(pse, angle)); i want this [B]pse[/B] passed variable to be my soon to be created [B]new PlannedSpaceShip(pls.getx(), pls.gety(), dx, dy)[/B] object from the [B]launchFPSpaceShip[/B] method, not the in class declared [B]private PointSimulationElement pse;[/B]
        //cc.addCommand(cd.execute()); doesn't let...
        //cc.addCommand(new ChangeDirection(pse, angle));
    }

here is my code, i create the plannedspaceship object and i when i click change direction/speed then that changing would be made exactly to that ship (would be better that before i click on launch it, i would choose the speed/angle for it and when launches the commands are implemented already). thanks again, i really can't get atm. i thought that this kind of problem is whole field of programmin, tried to google for object access java but got only links to data access object topics...

Way too much code for most people to go thru.
To find out why the pointer is null you need to debug the program.
One way to debug your code is add more println() statements that show you when variable values change and when methods are called.

For the bit of code in red, can you make a small self contained program that compiles and executes to demonstrate your problem?

hey, thanks for the idea. i have made a little program which should convey my problem

package main;

import java.util.*;

class MainClass {
	
	Controller controller = new Controller();
	Ship ship;
	
	public MainClass() {
		
		this.controller.speedFactor(ship, 10);
		this.ship = this.controller.createShip(5);
		System.out.println(this.ship);
	}
	
	public static void main(String[] args) {
		new MainClass();
	}

} // end of class MainClass

class Controller {
	
	CommandControl cc = new CommandControl();
	Ship ship;
	
	public Ship createShip(int speed) {
		return new Ship(speed);
	}
	
	public void speedFactor(Ship ship, int factor) {
		cc.addCommand(new ChangeSpeed(ship, factor));
	}
	
	public void executeCommands(Ship ship) {
		cc.execute();
	}
	
	
} // end of class Controller

class Ship {
	CommandControl cc;
	
	int speed;
	
	public Ship(int speed) {
		this.speed = speed;
		cc = new CommandControl();
	}
	public String toString() {
		return "Ship speed: " + speed;
	}
} // end of class Ship

interface Command {
	public abstract void execute();
} // end of interface Command

class CommandControl implements Command {

	private List<Command> commands;
	
	public CommandControl() {
		commands = new LinkedList<Command>();
	}
	
	@Override
	public void execute() {
		for (Command com : commands) {
			runSingleCommand();
		}
	}
	
	public void addCommand(Command c) {
        ((LinkedList<Command>) commands).addLast(c);
    }

    public void runSingleCommand() {
        ((LinkedList<Command>) commands).getFirst().execute();
        ((LinkedList<Command>) commands).removeFirst();
    }
	
} // end of class CommandControl

class ChangeSpeed implements Command {
	
	Ship ship;
	int factor;
	
	public ChangeSpeed(Ship ship, int factor) {
		this.ship = ship;
		this.factor = factor;
	}

	@Override
	public void execute() {
		this.ship.speed = this.ship.speed * factor;
		
	}
	
} // end of class ChangeSpeed

how could i make that in my main class where i call out the ship, i want to bind my commands to that concrete ship (change it's speed).

i want to bind my commands to that concrete ship (change it's speed).

What do you mean by "bind my commands"?
I don't see any comments in your code indicating where you want to do what.


ChangeSpeed is a strange name for a class. Normally classes represent things not actions.

hi again. task of my original application is follow: i have 3 commands/buttons in my GUI - change speed factor (number by which is current speed multiplied), change direction, interval (ticks) between commands executing. So in my GUI i enter speed factor number, then interval number (after how many intervals next command is executed) then for example direction which is executed after n intervals which i entered and after that i click launch ship and these commands should apply to this concrete ship which i launched <- this is where i'm stuck

package main;

import java.util.*;

class MainClass {
	
	Controller controller = new Controller();
	Ship ship;
	
	public MainClass() {
		
		this.ship = this.controller.createShip(5); // ship created with initial speed of 5
		this.controller.speedFactor(ship, 10); // this command should apply to my created ship, speed should be after that 5*10 = 50
		System.out.println(this.ship); // Ship speed: 5
	}
	
	public static void main(String[] args) {
		new MainClass();
	}

} // end of class MainClass

class Controller {
	
	CommandControl cc = new CommandControl();
	Ship ship;
	
	/**
	 * creates a ship with it's starting speed
	 *  @return new ship
	 */
	public Ship createShip(int speed) {
		return new Ship(speed);
	}
	/**
	 * command-method which changes the speed of the ship
	 *  @param factor by which is speed multiplied
	 */
	public void speedFactor(Ship ship, int factor) {
		cc.addCommand(new ChangeSpeed(ship, factor));
	}
	/**
	 * executes the added commands for the ship in order
	 */
	public void executeCommands(Ship ship) {
		cc.execute();
	}
	
	
} // end of class Controller

class Ship {
	CommandControl cc;
	
	int speed;
	
	public Ship(int speed) {
		this.speed = speed;
		cc = new CommandControl(); // the commands are applied to that ship
	}
	public String toString() {
		return "Ship speed: " + speed;
	}
} // end of class Ship

interface Command {
	public abstract void execute();
} // end of interface Command

class CommandControl implements Command {

	private List<Command> commands;
	
	public CommandControl() {
		commands = new LinkedList<Command>();
	}
	
	/**
	 * loops and executes each added command
	 */
	public void execute() {
		for (Command com : commands) {
			runSingleCommand();
		}
	}
	
	public void addCommand(Command c) {
        ((LinkedList<Command>) commands).addLast(c);
    }
	
	/**
	 * runs a single command from the list and removes it.
	 */
    public void runSingleCommand() {
        ((LinkedList<Command>) commands).getFirst().execute();
        ((LinkedList<Command>) commands).removeFirst();
    }
	
} // end of class CommandControl

class ChangeSpeed implements Command {
	
	Ship ship;
	int factor;
	
	/**
	 * creates a new command for the ship
	 */
	public ChangeSpeed(Ship ship, int factor) {
		this.ship = ship;
		this.factor = factor;
	}
	
	/**
	 * changes the speed of the ship by multiplying with factor
	 */
	public void execute() {
		this.ship.speed = this.ship.speed * factor;
	}
	
} // end of class ChangeSpeed

so i minimized my problem with the only 1 command. all that is done with command pattern (task is that in future new types of commands could be added easily).
i'm not even sure if my logic is correct for that command applying to my created ship. I'm still trying to get any idea or solution how to do that, any help would be appreciated

after that i click launch ship and these commands should apply to this concrete ship which i launched

Let me rephrase your problem: You receive commands to be applied to a future event(launch of ship) and need to queue them until the ship is launched (new Ship object created). When the new Ship object is created, then the commands in the queue should immediately be applied to the ship.

Let me rephrase your problem: You receive commands to be applied to a future event(launch of ship) and need to queue them until the ship is launched (new Ship object created). When the new Ship object is created, then the commands in the queue should immediately be applied to the ship.

good morning. yes exactly as you said. but i don't have idea how would i do that. any idea or is there any example in the internet?

Some more observations on your code.
The method doesn't use its argument:

public void executeCommands(Ship ship) {
		cc.execute();
	}

On line 13 you have queued a command for the ship.
You now need to execute it to change by speed by the factor
The println() shows the value before the execution.
Execute the command and do the println again should show the new speed.

ship = this.controller.createShip(5); // ship created
		this.controller.speedFactor(ship, 10); // this command should apply to my created ship
		this.controller.executeCommands(ship);
		System.out.println(ship);

total crap, after this i get this error

Exception in thread "main" java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:761)
at java.util.LinkedList$ListItr.next(LinkedList.java:696)
at main.CommandControl.execute(MainClass.java:83)
at main.Controller.executeCommands(MainClass.java:47)
at main.MainClass.<init>(MainClass.java:14)
at main.MainClass.main(MainClass.java:19)

is this good approach at all that commands implementing is in the command class not the ship class at all ?
by the way, im not even sure that i have coded my methods correctly to apply commands to future event

Read the API doc for ConcurrentModificationException

In one place you are going through the List:

for (Command com : commands) {

and then in another place you try to access the list and change it:

   ((LinkedList<Command>) commands).getFirst().execute();
    ((LinkedList<Command>) commands).removeFirst();

BTW why do you define commands as a List and then cast it to LinkedList every time you use it. Why not define it as a LinkedList and not do any cast?

hi again. i'm at work now, can't concrentrate on this small prog, so i had time to make only a few changes.
i've read that usual java iterator will do the work and omit concurrent modification expception
now it is so:

public void execute() {
        /*for (Command com : commands) {
        commands.getFirst().execute();
        commands.removeFirst();
        }*/
        Iterator<Command> iterator;
        iterator = commands.iterator();
        while (iterator.hasNext()) {
            runSingleCommand();
        }
    }

my main classs:

ship = this.controller.createShip(5); // ship created
        this.controller.speedFactor(ship, 10); // this command should apply to my created ship
        this.controller.executeCommands(ship);
        System.out.println(ship);
        this.controller.speedFactor(ship, 100);
        this.controller.executeCommands(ship);
        System.out.println(ship);

prints out well.
thu i'm concerned if it's right approach to implement commands in the command class not the ship class itself. maybe i should implement the ship's inner logic in the ship itself?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.