my task is to create a gui for a list of cars, bus,bicycle etc. and the program should be able to add and remove to the car in store. so i wrote this code below using netbeans IDE.

package vehicleregister;
import java.awt.*;
import java.awt.event.*;
public class VehicleRegister extends Frame implements WindowListener,ActionListener {
    private Label label1;
    private Label label2;
    private Label label3;
    private Label label4;
    private Label label5;
    private Label label6;
    private Label label7;
    private Button btnAddBuss;
    private Button btnRemoveBuss;
    private Button btnAddCar;
    private Button btnRemoveCar;
    private Button btnAddVan;
    private Button btnRemoveVan;
    private Button btnAddBicycle;
    private Button btnRemoveBicycle;
    private Button btnAddOthers;
    private Button btnRemoveOthers;
    private List stock;
    private int carCount=50;
    private int bussCount=40;
    private int vanCount=60;
    private int bicycleCount=55;
    private int otherCount;
    private TextField tf;



    public VehicleRegister(String title){
    super(title);
    setBackground(SystemColor.YELLOW);
    addWindowListener(this);
    setLayout(null);

    label1=new Label("CLICK THE CORRESPONDING ADD OR REMOVE BUTTON FOR THE TYPE");
    label1.setBounds(55,50,450,30);
    add(label1);

    label2=new Label("OF VEHICLE YOU WANT TO ADD TO, OR REMOVE FROM THOSE IN STOCK");
    label2.setBounds(55,70,450,30);
    this.add(label2);

       btnAddBuss=new Button("ADD");
       btnAddBuss.setBounds(150,120,50,30);
       btnAddBuss.addActionListener(this);
       add(btnAddBuss);

       btnRemoveBuss=new Button("REMOVE");
       btnRemoveBuss.setBounds(250,120,60,30);
       btnRemoveBuss.addActionListener(this);
       add(btnRemoveBuss);

       btnAddCar=new Button("ADD");
       btnAddCar.setBounds(150,160,50,30);
       btnAddCar.addActionListener(this);
       add(btnAddCar);

       btnRemoveCar=new Button("REMOVE");
       btnRemoveCar.setBounds(250,160,60,30);
       btnRemoveCar.addActionListener(this);
       add(btnRemoveCar);

       btnAddVan=new Button("ADD");
       btnAddVan.setBounds(150,200,50,30);
       btnAddVan.addActionListener(this);
       add(btnAddVan);

       btnRemoveVan=new Button("REMOVE");
       btnRemoveVan.setBounds(250,200,60,30);
       btnRemoveVan.addActionListener(this);
       add(btnRemoveVan);

       btnAddBicycle=new Button("ADD");
       btnAddBicycle.setBounds(150,240,50,30);
       btnAddBicycle.addActionListener(this);
       add(btnAddBicycle);

       btnRemoveBicycle=new Button("REMOVE");
       btnRemoveBicycle.setBounds(250,240,60,30);
       btnRemoveBicycle.addActionListener(this);
       add(btnRemoveBicycle);

       btnAddOthers=new Button("ADD");
       btnAddOthers.setBounds(150,280,50,30);
       btnAddOthers.addActionListener(this);
       add(btnAddOthers);

       btnRemoveOthers=new Button("REMOVE");
       btnRemoveOthers.setBounds(250,280,60,30);
       btnRemoveOthers.addActionListener(this);
       add(btnRemoveOthers);

       label3=new Label("BUSS");
       label3.setBounds(55,120,60,30);
       add(label3);

       label4=new Label("CAR");
       label4.setBounds(55,160,60,30);
       add(label4);

       label5=new Label("VAN");
       label5.setBounds(55,200,60,30);
       add(label5);

       label6=new Label("BICYCLE");
       label6.setBounds(55,240,60,30);
       add(label6);

       label7=new Label("OTHER");
       label7.setBounds(55,280,60,30);
       add(label7);

       stock=new List();
       stock.setBounds(25,320,500,50);
       add(stock);
       tf= new TextField();
       add(tf);
       tf.setBounds(350,120,150,60);

    }

    public static void main(String[] args) {
        VehicleRegister frame = new VehicleRegister("VEHICLE REGISTER APPLICATION");
        frame.setSize(550,400);
        frame.setLocation(450,250);
        frame.setVisible(true);
    }

    public void windowActivated(WindowEvent e) {
    }
    public void windowClosed(WindowEvent e) {
    }
    public void windowClosing(WindowEvent e) {
       dispose();
       System.exit(0);
    }
    public void windowDeactivated(WindowEvent e) {
    }
    public void windowDeiconified(WindowEvent e) {
    }
    public void windowIconified(WindowEvent e) {
    }
    public void windowOpened(WindowEvent e) {
    }

    public void actionPerformed(ActionEvent e) {
        int input;
        if (e.getSource()==btnAddBuss)
        {
          input=Integer.parseInt(tf.getText());
          bussCount=input + bussCount;
          stock.removeAll();
          stock.add("VEHICLES NOW IN STOCK");
          stock.add("BUS     "+bussCount);stock.add("CAR     "+ carCount);stock.add("VAN     "+ vanCount);
          stock.add("BICYCLE     "+ bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
        else if (e.getSource()==btnRemoveBuss)
        {
             input=Integer.parseInt(tf.getText());
             bussCount=bussCount  - input;
          stock.removeAll();
          stock.add("VEHICLES NOW IN STOCK");
          stock.add("BUS     "+ bussCount);stock.add("CAR     "+ carCount);stock.add("VAN     "+ vanCount);
          stock.add("BICYCLE     "+ bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
        else if (e.getSource()==btnAddCar)
        {
             input=Integer.parseInt(tf.getText());
             carCount=input + carCount;
          stock.removeAll();
          stock.add("VEHICLES NOW IN STOCK");
          stock.add("BUS     "+ bussCount);stock.add("CAR     "+ ++carCount);stock.add("VAN     "+ vanCount);
          stock.add("BICYCLE     "+ bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
        else if (e.getSource()==btnRemoveCar)
        {
             input=Integer.parseInt(tf.getText());
             carCount=carCount  -  input;
          stock.removeAll();
          stock.add("VEHICLES NOW IN STOCK");
          stock.add("BUS     "+ bussCount);stock.add("CAR     "+ carCount);stock.add("VAN     "+ vanCount);
          stock.add("BICYCLE     "+ bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
        else if (e.getSource()==btnAddVan)
        {
             input=Integer.parseInt(tf.getText());
             vanCount=input + vanCount;
         stock.removeAll();
          stock.add("VEHICLES NOW IN STOCK");
         stock.add("BUS     "+ bussCount);stock.add("CAR     "+ carCount);stock.add("VAN     "+vanCount);
         stock.add("BICYCLE     "+ bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
        else if (e.getSource()==btnRemoveVan)
        {
             input=Integer.parseInt(tf.getText());
             vanCount=vanCount  - input;
         stock.removeAll();
          stock.add("VEHICLES NOW IN STOCK");
         stock.add("BUS     "+ bussCount);stock.add("CAR     "+ carCount);stock.add("VAN     "+vanCount);
         stock.add("BICYCLE     "+ bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
        else if (e.getSource()==btnAddBicycle)
        {
             input=Integer.parseInt(tf.getText());
             bicycleCount=input + bicycleCount;
          stock.removeAll();
         stock.add("VEHICLES NOW IN STOCK");
         stock.add("BUS     "+ bussCount);stock.add("CAR     "+ carCount);stock.add("VAN     "+ vanCount);
         stock.add("BICYCLE     "+bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
         else if (e.getSource()==btnRemoveBicycle)
        {
              input=Integer.parseInt(tf.getText());
              bicycleCount=bicycleCount - input;
         stock.removeAll();
           stock.add("VEHICLES NOW IN STOCK");
         stock.add("BUS     "+ bussCount);stock.add("CAR     "+ carCount);stock.add("VAN     "+ vanCount);
         stock.add("BICYCLE     "+bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
         else if (e.getSource()==btnAddOthers)
        {
              input=Integer.parseInt(tf.getText());
              otherCount=input + otherCount;
         stock.removeAll();
           stock.add("VEHICLES NOW IN STOCK");
         stock.add("BUS     "+ bussCount);stock.add("CAR     "+ carCount);stock.add("VAN     "+ vanCount);
         stock.add("BICYCLE     "+ bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
         else if (e.getSource()==btnRemoveOthers)
        {
              input=Integer.parseInt(tf.getText());
               otherCount=otherCount - input;
         stock.removeAll();
          stock.add("VEHICLES NOW IN STOCK");
         stock.add("BUS     "+ bussCount);stock.add("CAR     "+ carCount);stock.add("VAN     "+ vanCount);
         stock.add("BICYCLE     "+ bicycleCount);stock.add("OTHER VEHICLE TYPE    "+ otherCount);
        }
    }


}

But my task is to Use android environment but I dont know how to go about it. can anyone help me out?

Recommended Answers

All 4 Replies

i googled and found this link. developer.android.com

with any of these phones you have to download their SDK. They use a java like language if they are java compatible but are not exactly java as we know it from sun. I had limited experience doing this with the LG phone SDK which is also java like. The developer tool download you get with the SDK has a simulator to run your code and see a replica of a phone screen on your desktop.

Mike

@BestJewSinceJC JAva Microedition is not compatible with Android.

As adams161 pointed there is SDK for Android that can be added as plugin to Eclipse, IntelliJ IDEA or NetBeans (however there been some issues under NB, so far Eclipse has the best). Android SDK provide programming environment for you and also very functional emulator where you can test your applications without need of actual device. I have to say that this emulator is far more sophisticated then emulators provided by Java ME WTK 2.5.2 or SDK 3.0.

In general you can say that Android development is more or less of using Java API with difference here or there. On top of that lots of things can be done through XML files configurations.
Have look on some books like these which will help you. (I wanted to learn little about Android too, but so far work requirement kept me out of mobile development:( )

@BestJewSinceJC thanks but am talking about using it on eclipse and @adams161 thanks so much its was a little bit helpful and @peter_budo thanks i have already add the plugins on eclipse and now with the links to give to me am working something out...Thanks so much

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.