Ok, I am trying to do another class project and I keep getting a NullPointerException showing up on the txtOutput line. The main goal of this project is to have a driver program with the 2 paned tab. One tab the user enters the data to add a Vehicle to a VECTOR and the other will have a JPanel that will display it. I know my JPanel isn't set up correctly to display. I am trying to get the first tab to work. Whenever I punch it is, I can't get Vehicle added to show up, just NullPointerException. If you notice something else, feel free to offer help as well.
I had shoulder surgery earlier this semester and couldn't do the projects. The teacher is letting me turn them in late - by tonight. There is 6 and this is only 3. I've been up too long trying to get these done and have probably made stupid mistakes.
import javax.swing.*; public class PRJ03 extends JFrame { public static void main (String [] args) { Vehicle vehicle; pAddVehicle pnlAdd; pShowVehicle pnlShow; JTabbedPane tpDisplay; vehicle = new Vehicle(); pnlAdd = new pAddVehicle(); pnlShow = new pShowVehicle(); tpDisplay = new JTabbedPane(JTabbedPane.BOTTOM); pnlAdd.setInventory(vehicle); tpDisplay.addTab("Add Vehicle", pnlAdd); tpDisplay.addTab("Vehicles", pnlShow); PRJ03 frmApp = new PRJ03(); frmApp.add(tpDisplay); frmApp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmApp.setSize(700,500); frmApp.setVisible(true); } }import java.util.Vector; public class Vehicle { private int count; SingleVehicle tempCar; Vector <SingleVehicle> vVehicle = new Vector<SingleVehicle>(); public Vehicle() { count = 0; } public int getCount() { return count; } public void addItem(String make, String model, String color, int numDoors, int numCylinders, double price)throws VehicleException { tempCar = new SingleVehicle(make, model, color, numDoors, numCylinders, price); vVehicle.add(tempCar); count++; } }public class SingleVehicle { String make = ""; String model = ""; String color = ""; int numDoors = 0; int numCylinders = 0; double price = 0.0; public SingleVehicle() { this.make = ""; this.model = ""; this.color = ""; this.numDoors = 0; this.numCylinders = 0; this.price = 0.0; } public SingleVehicle(String make, String model, String color, int numDoors, int numCylinders, double price) { this.make = make; this.model = model; this.color = color; this.numDoors = numDoors; this.numCylinders = numCylinders; this.price = price; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public String getMake() { return make; } public void setMake(String make) { this.make = make; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public int getNumDoors() { return numDoors; } public void setNumDoors(int numDoors) { this.numDoors = numDoors; } public int getNumCylinders() { return numCylinders; } public void setNumCylinders(int numCylinders) { this.numCylinders = numCylinders; } }import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class pAddVehicle extends JPanel implements ActionListener { private Vehicle vehicle; private pShowVehicle pnlShow; private JLabel lblMake; private JLabel lblModel; private JLabel lblColor; private JLabel lblNumDoors; private JLabel lblNumCylinders; private JLabel lblPrice; private JTextField txtMake; private JTextField txtModel; private JTextField txtColor; private JTextField txtNumDoors; private JTextField txtNumCylinders; private JTextField txtPrice; private JTextField txtDisplay; private JButton btnAddItem; private JPanel ROW1; private JPanel ROW2; private JPanel ROW3; private JPanel ROW4; private JPanel ROW5; private JPanel ROW6; private JPanel ROW7; private JPanel ROW8; public pAddVehicle() { lblMake = new JLabel("Car's Make"); lblModel = new JLabel("Car's Model"); lblColor = new JLabel("Car's Color"); lblNumDoors = new JLabel("Number of Doors"); lblNumCylinders = new JLabel("Number of Cylinders"); lblPrice = new JLabel("Price"); txtMake = new JTextField(20); txtModel = new JTextField(20); txtColor = new JTextField(10); txtNumDoors = new JTextField(2); txtNumCylinders = new JTextField(2); txtPrice = new JTextField(5); txtDisplay = new JTextField(50); btnAddItem = new JButton("Add to Inventory"); ROW1 = new JPanel(); ROW2 = new JPanel(); ROW3 = new JPanel(); ROW4 = new JPanel(); ROW5 = new JPanel(); ROW6 = new JPanel(); ROW7 = new JPanel(); ROW8 = new JPanel(); btnAddItem.setActionCommand("additem"); btnAddItem.addActionListener(this); ROW1.add(lblMake); ROW1.add(txtMake); ROW2.add(lblModel); ROW2.add(txtModel); ROW3.add(lblColor); ROW3.add(txtColor); ROW4.add(lblNumDoors); ROW4.add(txtNumDoors); ROW5.add(lblNumCylinders); ROW5.add(txtNumCylinders); ROW6.add(lblPrice); ROW6.add(txtPrice); ROW7.add(btnAddItem); ROW8.add(txtDisplay); setLayout(new GridLayout(8, 1)); add(ROW1); add(ROW2); add(ROW3); add(ROW4); add(ROW5); add(ROW6); add(ROW7); add(ROW8); } public void setInventory(Vehicle i) { vehicle = i; } public void setOrderPanel(pShowVehicle p) { pnlShow = p; } @Override public void actionPerformed(ActionEvent evt) { String ma; String mo; String co; int numD; int numC; double p; if (evt.getActionCommand().equals("additem")) { try { txtDisplay.setText(""); ma = txtMake.getText(); mo = txtModel.getText(); co = txtColor.getText(); numD = Integer.parseInt(txtNumDoors.getText()); numC = Integer.parseInt(txtNumCylinders.getText()); p = Double.parseDouble(txtPrice.getText()); vehicle.addItem(ma, mo,co, numD, numC, p); txtDisplay.setText("Vehicle added"); pnlShow.doSomething(); } catch (VehicleException ex) { txtDisplay.setText(ex.toString()); } catch (NumberFormatException ex) { txtDisplay.setText("Please Type Valid Numbers!"); } catch (Exception ex) { txtDisplay.setText(ex.toString()); } } } }import javax.swing.*; public class pShowVehicle extends JPanel { private Vehicle vehicle; JScrollPane spOrder; JTextArea taOrder; JPanel ROW1; public pShowVehicle() { taOrder = new JTextArea(20, 60); spOrder = new JScrollPane(taOrder); ROW1 = new JPanel(); ROW1.add(spOrder); add(ROW1); } public void doSomething() { taOrder.setText("ZZZZZZZZZZZ"); } }