I've redone my code and have tried to emulate the examples from the Oracle website but I still keep getting errors. Most of them are <identifier> expected. In this case the bolded part is where I am getting a compilation error.
/* Trip Calc Project
*
*
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class TripCalc extends JFrame implements ActionListener
{
String[] typeStrings = { "Compact", "Mid-Size", "Luxury", "Suv" };
String[] fuelStrings = { "Leaded", "Unleaded", "Premium", "Diesel" };
String[] startStrings = { "Bemidji", "Detroit Lakes", "Duluth", "Minneapolis", "St. Cloud", "Rochester" };
String[] endStrings = { "Daytona", "Bristol", "Talladega", "Darlington", "Charlotte", "Richmond" };
//construct components
JLabel typePrompt = new JLabel("Vehicle Type");
JComboBox typeList = new JComboBox(typeStrings);
[B]combo.addActionListener(this);[/B]
JTextPane typePane = new JTextPane();
JLabel fuelPrompt = new JLabel("Fuel Type");
JComboBox fuelList = new JComboBox(fuelStrings);
JTextPane fuelPane = new JTextPane();
JLabel startPrompt = new JLabel("Starting Location");
JComboBox startList = new JComboBox(startStrings);
JTextPane startPane = new JTextPane();
JLabel endPrompt = new JLabel("Ending Location");
JComboBox endList = new JComboBox(endStrings);
JTextPane endPane = new JTextPane();
// Panel Creation
JPanel firstRow = new JPanel();
JPanel secondRow = new JPanel();
// Panel for Fields and Buttons
JPanel fieldPanel = new JPanel();
JPanel buttonPanel = new JPanel();
// Construct Labels and TextBoxes
JLabel Miles = new JLabel("Miles planning to travel" );
JTextField distance = new JTextField(5);
JLabel Fuelcost = new JLabel("What is the price per gallon?" );
JTextField fuelprice = new JTextField(3);
JLabel Total = new JLabel("Your total cost for the trip will be" );
JTextField totalcost = new JTextField(6);
JButton submitButton = new JButton("Submit");
JButton clearButton = new JButton("Clear Fields");
//create the content pane
public Container createContentPane()
{
//construct and populate the north panel
JPanel northPanel = new JPanel();
northPanel.setLayout(new FlowLayout());
northPanel.add(typePrompt);
northPanel.add(typeList);
northPanel.add(fuelPrompt);
northPanel.add(fuelList);
northPanel.add(startPrompt);
northPanel.add(startList);
northPanel.add(endPrompt);
northPanel.add(endList);
JPanel southPanel = new JPanel();
southPanel.setLayout(new FlowLayout());
southPanel.add(submitButton);
southPanel.add(clearButton);
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new FlowLayout());
centerPanel.add(Miles);
centerPanel.add(distance);
centerPanel.add(Fuelcost);
centerPanel.add(fuelprice);
centerPanel.add(Total);
centerPanel.add(totalcost);
//createContainer and set attributes
Container f = getContentPane();
setLayout(new BorderLayout(40,40));
fieldPanel.setLayout(new GridLayout(1,1));
buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
add(northPanel,BorderLayout.NORTH);
add(southPanel,BorderLayout.SOUTH);
add(centerPanel,BorderLayout.CENTER);
setLocation(200,200);
return f;
}
//main method executes at run time
public static void main(String args[])
{
TripCalc f = new TripCalc();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setContentPane(f.createContentPane());
f.setTitle("Trip Calculator");
f.setSize(800,300);
f.setVisible(true);
}
// event to process user clicks
public void actionPerformed(ActionEvent e)
{
JComboBox typeList = (JComboBox)e.getSource();
String typeStrings = (String) typeList.getSelectedItem();
}
}