ScatmanTom 0 Newbie Poster

Hello there!

I'm new here, like to say hello to you all. I'll probably be needing help on plenty more themes soon as I'm looking to continue this subject alone when the Semester finishes. I'm studying Java and just can't get my head around Multithreading. Wonder if anyone could help me with the problem that I'm having?

Basically, I have a JForm that has a JPanel which contains my class information. This was done by adding it to the beans pallette etc... (Don't know if this is standard practice but it's how we were taught). The problem is, when I try to create a new instance of my class, it tells me:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: Visual01: method <init>()V not found

now, I've implemented Runnable but I'm pretty sure this is completely unrelated to the actual thread, and more related to the form build. However when I try to re-add the class to my pallette it says:

No JavaBean found under selected Nodes

The reason I'm trying to do this is that I'm creating a space shuttle simulator and I've got it to work and display fine with just the shuttle. But when it comes to displaying two (e.g. asteroids/alien craft etc...) it's no-go. I have also got Mars to display okay.

I think if someone can help me get it to create an instance of Visual01 and then allow it to compile I'll be able to take it from here.

Any help would be much appreciated, thanks very much! Code is pasted below.

Tom

--------------------------- Form --------------------------------------------

/*
 * NASAInterface.java
 *
 * Created on 01 December 2006, 21:03
 */
/**
 *
 * @author  Tom
 */
//import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeListener;
import javax.swing.*;
import javax.swing.ProgressMonitor;
import java.util.*;
import java.text.*;
import java.lang.reflect.InvocationTargetException;
import java.beans.*;
import java.util.Random;
public class NASAInterface extends javax.swing.JFrame implements Runnable{

    public void run() {

        while(true){
            jProgressBar2.setValue(rA);
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex){

            }
            rA++;
            if(jProgressBar2.getValue() > 75) {
                jProgressBar2.setForeground(Color.RED);
            }
            else {
                jProgressBar2.setForeground(Color.GREEN);
            }
        }
    }

    //Thread th = new Thread(this);
    //th.start();

    /*public void update(Runnable r) {
        try {
        SwingUtilities.invokeAndWait(r);
        }
        catch (InterruptedException ex){

        }
        catch (InvocationTargetException iTE){

        }
    }*/


    public void stop() {

    }



    int rX;// = 10;
    int rY;// = 10;
    int rW = 5;
    int rH = 5;
    int rS = 1000;
    int rXM = +1;
    int rYM = +1;

    int rA =1;

    /** Creates new form NASAInterface */
    public NASAInterface() {
        initComponents();

        Thread t1 = new Thread(this);
        t1.start();
    }
    //------------------------------------
    String msg;
    String count;

    //------------------------------------

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
    private void initComponents() {
        gearControl = new javax.swing.JSlider();
        gearStickLabel = new javax.swing.JLabel();
        jProgressBar1 = new javax.swing.JProgressBar();
        jLabel1 = new javax.swing.JLabel();
        jProgressBar2 = new javax.swing.JProgressBar();
        startButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        northWestButton = new javax.swing.JButton();
        northButton = new javax.swing.JButton();
        northEastButton = new javax.swing.JButton();
        westButton = new javax.swing.JButton();
        blank = new javax.swing.JButton();
        eastButton = new javax.swing.JButton();
        southWestButton = new javax.swing.JButton();
        southButton = new javax.swing.JButton();
        southEastButton = new javax.swing.JButton();
        rocketsButton = new javax.swing.JButton();
        simulationButton = new javax.swing.JButton();
        helpButton = new javax.swing.JButton();
        interfacePanel = new javax.swing.JPanel();
        visual011 = new Visual01();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        newsFeed = new javax.swing.JLabel();
        jProgressBar3 = new javax.swing.JProgressBar();
        jLabel3 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel4 = new javax.swing.JLabel();
        jProgressBar4 = new javax.swing.JProgressBar();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        gearControl.setForeground(new java.awt.Color(0, 0, 0));
        gearControl.setMajorTickSpacing(1);
        gearControl.setMaximum(5);
        gearControl.setMinimum(1);
        gearControl.setOrientation(javax.swing.JSlider.VERTICAL);
        gearControl.setPaintLabels(true);
        gearControl.setPaintTicks(true);
        gearControl.setSnapToTicks(true);
        gearControl.setValue(1);
        gearControl.setEnabled(false);
        gearControl.setFocusable(false);
        gearControl.setRequestFocusEnabled(false);
        gearControl.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                gearControlStateChanged(evt);
            }
        });
        gearStickLabel.setText("Gear:");
        jProgressBar1.setForeground(new java.awt.Color(255, 255, 0));
        jProgressBar1.setValue(80);
        jProgressBar1.setFocusable(false);
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Acceleration:");
        jProgressBar2.setBackground(new java.awt.Color(0, 0, 0));
        jProgressBar2.setForeground(new java.awt.Color(102, 255, 51));
        jProgressBar2.setOrientation(1);
        jProgressBar2.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jProgressBar2PropertyChange(evt);
            }
        });
        startButton.setText("Start Simulation");
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });
        jPanel1.setLayout(new java.awt.GridLayout(4, 3));
        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        northWestButton.setText("NW");
        northWestButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                northWestButtonActionPerformed(evt);
            }
        });
        jPanel1.add(northWestButton);
        northButton.setText("N");
        northButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                northButtonActionPerformed(evt);
            }
        });
        jPanel1.add(northButton);
        northEastButton.setText("NE");
        northEastButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                northEastButtonActionPerformed(evt);
            }
        });
        jPanel1.add(northEastButton);
        westButton.setText("W");
        westButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                westButtonActionPerformed(evt);
            }
        });
        jPanel1.add(westButton);
        blank.setBackground(new java.awt.Color(153, 153, 153));
        jPanel1.add(blank);
        eastButton.setText("E");
        eastButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eastButtonActionPerformed(evt);
            }
        });
        jPanel1.add(eastButton);
        southWestButton.setText("SW");
        southWestButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                southWestButtonActionPerformed(evt);
            }
        });
        jPanel1.add(southWestButton);
        southButton.setText("S");
        southButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                southButtonActionPerformed(evt);
            }
        });
        jPanel1.add(southButton);
        southEastButton.setText("SE");
        southEastButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                southEastButtonActionPerformed(evt);
            }
        });
        jPanel1.add(southEastButton);
        rocketsButton.setBackground(new java.awt.Color(255, 0, 0));
        rocketsButton.setForeground(new java.awt.Color(255, 255, 255));
        rocketsButton.setText("Rockets");
        jPanel1.add(rocketsButton);
        simulationButton.setBackground(new java.awt.Color(0, 204, 0));
        simulationButton.setForeground(new java.awt.Color(255, 255, 255));
        simulationButton.setText("Simulation");
        jPanel1.add(simulationButton);
        helpButton.setBackground(new java.awt.Color(0, 51, 255));
        helpButton.setForeground(new java.awt.Color(255, 255, 255));
        helpButton.setText("Help");
        jPanel1.add(helpButton);
        interfacePanel.setBackground(new java.awt.Color(0, 0, 0));
        visual011.setBackground(new java.awt.Color(0, 0, 0));
        visual011.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        org.jdesktop.layout.GroupLayout visual011Layout = new org.jdesktop.layout.GroupLayout(visual011);
        visual011.setLayout(visual011Layout);
        visual011Layout.setHorizontalGroup(
            visual011Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 781, Short.MAX_VALUE)
        );
        visual011Layout.setVerticalGroup(
            visual011Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 339, Short.MAX_VALUE)
        );
        org.jdesktop.layout.GroupLayout interfacePanelLayout = new org.jdesktop.layout.GroupLayout(interfacePanel);
        interfacePanel.setLayout(interfacePanelLayout);
        interfacePanelLayout.setHorizontalGroup(
            interfacePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(visual011, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        interfacePanelLayout.setVerticalGroup(
            interfacePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(visual011, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jLabel2.setText("Rocket Fuel:");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });
        newsFeed.setBackground(new java.awt.Color(0, 0, 0));
        newsFeed.setFont(new java.awt.Font("Courier New", 1, 14));
        newsFeed.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        newsFeed.setText("Mars Lander on-board News Feed...");
        newsFeed.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jProgressBar3.setForeground(new java.awt.Color(0, 51, 204));
        jProgressBar3.setValue(100);
        jLabel3.setText("Shuttle Health:");
        jLabel4.setText("Temperature:");
        jProgressBar4.setForeground(new java.awt.Color(255, 0, 0));
        jProgressBar4.setValue(50);
        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, interfacePanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, startButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 783, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(gearControl, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 38, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                            .add(gearStickLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(47, 47, 47)
                                .add(jProgressBar2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(layout.createSequentialGroup()
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(newsFeed, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE))
                                    .add(layout.createSequentialGroup()
                                        .add(14, 14, 14)
                                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, jSeparator1)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                                    .add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE))
                                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                                    .add(jProgressBar3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .add(jProgressBar4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 228, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 19, Short.MAX_VALUE))))
                            .add(layout.createSequentialGroup()
                                .add(12, 12, 12)
                                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 88, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(interfacePanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 190, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(gearStickLabel)
                            .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, gearControl, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jProgressBar2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)
                                    .add(layout.createSequentialGroup()
                                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(layout.createSequentialGroup()
                                                .add(jLabel2)
                                                .add(8, 8, 8)
                                                .add(jLabel3))
                                            .add(layout.createSequentialGroup()
                                                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                .add(jProgressBar3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(jLabel4)
                                            .add(jProgressBar4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 79, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(newsFeed, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 26, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                            .add(layout.createSequentialGroup()
                                .add(41, 41, 41)
                                .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(startButton)
                .addContainerGap())
        );
        pack();
    }// </editor-fold>                        

    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {                                      
        gearControl.setValue(gearControl.getValue() - 1 );
        rA = 0;
        jProgressBar2.setForeground(Color.GREEN);
    }                                     

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                      
        if(jProgressBar2.getValue() >= 75) {
            gearControl.setValue(gearControl.getValue() + 1);
            jProgressBar2.setForeground(Color.GREEN);
        }
        else {
            rA = 0;
            newsFeed.setText("BAD GEAR CHANGE, SHUTTLE DAMAGED...");
            jProgressBar3.setValue(jProgressBar3.getValue() - 10);
            jProgressBar2.setForeground(Color.GREEN);
        }

    }                                     

    private void northWestButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                
        rXM = -1;
        rYM = -1;
        rX = rX + rXM;
        rY = rY + rYM;

        visual011.RocketDirection(rXM, rYM);
    }                                               

    private void northButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        rXM = 0;
        rYM = -1;
        rX = rX + rXM;
        rY = rY + rYM;

        visual011.RocketDirection(rXM, rYM);
    }                                           

    private void northEastButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                
        rXM = 1;
        rYM = -1;
        rX = rX + rXM;
        rY = rY + rYM;

        visual011.RocketDirection(rXM, rYM);
    }                                               

    private void westButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
        rXM = -1;
        rYM = 0;
        rX = rX + rXM;
        rY = rY + rYM;

        visual011.RocketDirection(rXM, rYM);
    }                                          

    private void eastButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
        rXM = 1;
        rYM = 0;
        rX = rX + rXM;
        rY = rY + rYM;

        visual011.RocketDirection(rXM, rYM);
    }                                          

    private void southWestButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                
        rXM = -1;
        rYM = 1;
        rX = rX + rXM;
        rY = rY + rYM;

        visual011.RocketDirection(rXM, rYM);
    }                                               

    private void southButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        rXM = 0;
        rYM = 1;
        rX = rX + rXM;
        rY = rY + rYM;

        visual011.RocketDirection(rXM, rYM);
    }                                           

    private void southEastButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                
        rXM = 1;
        rYM = 1;
        rX = rX + rXM;
        rY = rY + rYM;

        visual011.RocketDirection(rXM, rYM);
    }                                               

    private void jProgressBar2PropertyChange(java.beans.PropertyChangeEvent evt) {                                             

    }                                            

    private void gearControlStateChanged(javax.swing.event.ChangeEvent evt) {                                         

        int currentGear = gearControl.getValue();

        switch(currentGear){
            case 1:
                rS = 1000;
                break;
            case 2:
                rS = 800;
                break;
            case 3:
                rS = 600;
                break;
            case 4:
                rS = 400;
                break;
            case 5:
                rS = 200;
                break;
            default:
                rS = 1000;
                break;
        }
        rA = 0;
        jProgressBar2.setForeground(Color.GREEN);
        visual011.RocketSpeed(rS);
    }                                        

    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        //rA = 0;
        int x = 5;
        int y = 5;
        int w = 5;
        int h = 5;

        visual011.draw(x, y, w, h);
        startButton.setEnabled(false);

    }                                           

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NASAInterface().setVisible(true);
            }
        });


    }



    //public void actionPerformed(ActionEvent evt) {

    //}




    int progress;


    public void propertyChange(int p) {

    }


    // Variables declaration - do not modify                     
    private javax.swing.JButton blank;
    private javax.swing.JButton eastButton;
    private javax.swing.JSlider gearControl;
    private javax.swing.JLabel gearStickLabel;
    private javax.swing.JButton helpButton;
    private javax.swing.JPanel interfacePanel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JProgressBar jProgressBar2;
    private javax.swing.JProgressBar jProgressBar3;
    private javax.swing.JProgressBar jProgressBar4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel newsFeed;
    private javax.swing.JButton northButton;
    private javax.swing.JButton northEastButton;
    private javax.swing.JButton northWestButton;
    private javax.swing.JButton rocketsButton;
    private javax.swing.JButton simulationButton;
    private javax.swing.JButton southButton;
    private javax.swing.JButton southEastButton;
    private javax.swing.JButton southWestButton;
    private javax.swing.JButton startButton;
    private Visual01 visual011;
    private javax.swing.JButton westButton;
    // End of variables declaration                   

}

------------------------- Class ----------------------------

/*
 * Visual01.java
 *
 * Created on 16 January 2007, 12:19
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
 import javax.swing.*;
 import java.awt.*;
/**
 *
 * @author Tom
 */
public class Visual01 extends JPanel implements Runnable {

    //Runnable r = new Visual01();
    //Thread t = new Thread(r);
    //t.start();
    Thread t;

    public void run() {

        t = new Thread(new Runnable() {
            public void run() {
                while(true){

                    try{
                        Thread.sleep(1000);
                    } catch(InterruptedException ex){
                        return;
                    }
                }

            }
        });
        t.start();  
    }

    /** Creates a new instance of Visual01 */

    public Visual01(int vXCoOrd, int vYCoOrd, int vWidth, int vHeight, int vXMovement, int vYMovement, int vSpeed, Color vColour) {
        x = vXCoOrd;
        y = vYCoOrd;
        w = vWidth;
        h = vHeight;
        xM = vXMovement;
        yM = vYMovement;
        s = vSpeed;
        c = vColour;

        //repaint();
    }

    Color nC = Color.WHITE;
    int nX = 5;
    int nY = 20;
    int nW = 4;
    int nH = 3;

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(rC);
        g.fillOval(rX, rY, rW, rH);

        draw(rX, rY, rW, rH);
        rX = rX + rXM;
        rY = rY + rYM;

        try{
            Thread.sleep(rS);
        }
        catch(InterruptedException ee) {
            return;
        } 
    }

    int x;
    int y;
    int w;
    int h;
    int xM;
    int yM;         
    int s;
    Color c;

    public void draw(int xCoOrd, int yCoOrd, int width, int height) {
        x = xCoOrd;
        y = yCoOrd;
        w = width;
        h = height;

        repaint();
    }

    //------------------ Rocket Creation and Methods-----------------------

    static int rX = 5;
    static int rY = 5;
    static int rW = 3;
    static int rH = 3;
    static int rXM = 1;
    static int rYM = 1;
    static int rS = 1000;
    static Color rC = Color.WHITE;

    public void Rocket(int rocketX, int rocketY, int rocketWidth, int rocketHeight, int rocketXMovement, int rocketYMovement, int rocketSpeed, Color rocketColor) {

        rX = rocketX;
        rY = rocketY;
        rW = rocketWidth;
        rH = rocketHeight;
        rXM = rocketXMovement;
        rYM = rocketYMovement;
        rS = rocketSpeed;
        rC = rocketColor;

    }


    public void RocketDirection(int changeRXM, int changeRYM) {
        rXM = changeRXM;
        rYM = changeRYM;
    }

    public void RocketSpeed(int changeRocketSpeed) {
        rS = changeRocketSpeed;
    }

    //-------------------- Asteroid Creation and Methods ------------------------

    static int aX = 60;
    static int aY = 60;
    static int aW = 10;
    static int aH = 10;
    static int aXM = 1;
    static int aYM = 1;
    static int aS = 70;
    static Color aC = Color.lightGray;

    public void Asteroid(int asteroidX, int asteroidY, int asteroidWidth, int asteroidHeight, int asteroidXMovement, int asteroidYMovement, int asteroidSpeed, Color asteroidColor) {
        aX = asteroidX;
        aY = asteroidY;
        aW = asteroidWidth;
        aH = asteroidHeight;
        aXM = asteroidXMovement;
        aYM = asteroidYMovement;
        aS = asteroidSpeed;
        aC = asteroidColor;

    }

    //-------------------- Mars Creation and Methods ----------------------------

    int marsX = 500;
    int marsY = 150;
    int mWidth = 600;
    int mHeight = 600;

    public void mars(int marsXCoOrd, int marsYCoOrd, int marsWidth, int marsHeight){
        marsX = marsXCoOrd;
        marsY = marsYCoOrd;
        marsWidth = marsWidth;
        marsHeight = marsHeight;
    } 
    public void paint(Graphics marsG){
        super.paint(marsG);
        marsG.setColor(Color.RED);
        marsG.fillOval(marsX, marsY, mWidth, mHeight);
    }

    public void main(String [] args) {
        System.out.println(rX);
    try {
        Thread.sleep(1000);
    }
    catch(InterruptedException ij) {
        return;
    }
    }
}
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.