I cannot for the life of me get my GUI to comeup with my deckPanel displayed along with my JButton that I intented to add an Action Listener to. THanks for looking. I am sure it has something to do with my object creation and method calls.
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class OrderCalc extends JFrame
{
private deckPanel decks;
private truckPanel trucks;
private wheelPanel wheels;
private extraPanel extras;
private JButton button;
//Constructor
public OrderCalc()
{
deckPanel dp = new deckPanel();
//set title
setTitle("Decks, Trucks, Wheels & Accessories Calculator");
//specify an action for the close button
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//add a flow layout manager
setLayout(new BorderLayout());
//create the object panels
trucks = new truckPanel();
wheels = new wheelPanel();
extras = new extraPanel();
//create the button panel
buildButtonPanel();
dp.deckPanel();
//add the components to the pane
add(decks, BorderLayout.NORTH);
add(trucks, BorderLayout.EAST);
add(wheels, BorderLayout.WEST);
add(extras, BorderLayout.SOUTH);
add(button, BorderLayout.CENTER);
//pack and display the window
pack();
setVisible(true);
}
//buildDeckPanel mothod adds a list containing the names of the decks to the panel.
private void buildButtonPanel()
{
button = new JButton();
button = new JButton("Calculate");
button.addActionListener(new JButtonListener());
}
public class JButtonListener
implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
}
}
//main
public static void main(String[] args)
{
new OrderCalc();
}
}
import javax.swing.*;
import java.awt.*;
public class deckPanel extends JPanel{
private String[] BOARDS = { "The Master Thrasher: $60", "The Dictator: $45",
"The Street King: $50"};
private JPanel deckPanel;
private JList deckList;
//constructor
public void deckPanel()
{
deckList = new JList(BOARDS);
deckList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
deckPanel.add(deckList);
}
}