I am not getting any compiling errors except warnings but the layout is working like it should. Using my text book I can create a JFrame with the panel and text boxes and I can create the JFrame with ComboBoxes it just doesn't tell me how to do them both at the same time. Any help would be appreciated. I don't want you to just give me the code which most here don't but if you have any suggested locations where this can be read so I can learn it that would be more helpful.
/* Chapter 7 * * */ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; public class TripCalc extends JFrame implements ActionListener { //construct components JLabel fuelPrompt = new JLabel("Fuel Costs"); JComboBox fuelCombo = new javax.swing.JComboBox(); JTextPane fuelPane = new JTextPane(); JLabel beginningPrompt = new JLabel("Starting Location"); JComboBox startCombo = new javax.swing.JComboBox(); JTextPane startPane = new JTextPane(); JLabel endPrompt = new JLabel("Ending Location"); JComboBox endCombo = new javax.swing.JComboBox(); 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(10); JLabel Fuelcost = new JLabel("What is the price per gallon/litre?"); JTextField fuelprice = new JTextField(5); JButton submitButton = new JButton("Submit"); //create the content pane public Container createContentPane() { //populate the JCombobox fuelCombo.addItem("Leaded"); fuelCombo.addItem("Unleaded"); fuelCombo.addItem("Super Unleaded"); fuelCombo.addItem("Diesel"); fuelCombo.addActionListener(this); fuelCombo.setToolTipText("Click on the type of fuel you will be using"); startCombo.addItem("Minneapolis"); startCombo.addItem("Duluth"); startCombo.addItem("Bemidji"); startCombo.addItem("Rochester"); startCombo.addItem("Detroit Lakes"); startCombo.addItem("St.Cloud"); startCombo.addActionListener(this); startCombo.setToolTipText("Click on your starting City."); endCombo.addItem("Daytona"); endCombo.addItem("Darlington"); endCombo.addItem("Las Vegas"); endCombo.addItem("Talladega"); endCombo.addItem("Richmond"); endCombo.addItem("Chicago"); endCombo.addActionListener(this); endCombo.setToolTipText("Click on your starting City."); //construct and populate the north panel JPanel northPanel = new JPanel(); northPanel.setLayout(new FlowLayout()); northPanel.add(fuelPrompt); northPanel.add(fuelCombo); northPanel.add(beginningPrompt); northPanel.add(startCombo); northPanel.add(endPrompt); northPanel.add(endCombo); //createContainer and set attributes Container f = getContentPane(); setLayout(new BorderLayout(20,20)); fieldPanel.setLayout(new GridLayout(4,2)); FlowLayout rowSetup = new FlowLayout(FlowLayout.LEFT,4,2); firstRow.setLayout(rowSetup); secondRow.setLayout(rowSetup); buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); add(northPanel,BorderLayout.NORTH); 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) { String arg = e.getActionCommand(); } }