Note that there are some explanatory texts on larger screens.

plurals
  1. POButton not appearing in Swing GUI
    primarykey
    data
    text
    <p>For my second programming assignment in my Java class, we have to create a Pizza Shop menu GUI. Everything appears on my GUI (including choices, boxes, radio buttons, etc.) except for the button ("Process Selection") you are supposed to click for calculating the total cost. The following is my code:</p> <pre><code>import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PizzaShop extends JFrame { private Topping t; private PizzaSize ps; private PizzaType pt; private JPanel buttonPanel; private JButton ProcessSelection; public PizzaShop() { super("Welcome To Home Pizza Shop"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new BorderLayout()); t = new Topping(); ps = new PizzaSize(); pt = new PizzaType(); createPanel(); add(t, BorderLayout.NORTH); add(ps, BorderLayout.WEST); add(pt, BorderLayout.CENTER); setVisible(true); } private void createPanel() { buttonPanel = new JPanel(); ProcessSelection = new JButton("Process Selection"); ProcessSelection.addActionListener(new calButton()); buttonPanel.add(ProcessSelection); } private class calButton implements ActionListener { public void actionPerformed(ActionEvent e) { double subtotal; subtotal = t.getTopping() + ps.getPizzaSize(); JOptionPane.showMessageDialog(null, "Your Order \n" + "Pizza Type" + pt.getPizzaType() + "\n" + "Amount Due" + subtotal); } } private class ExitButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { System.exit(0); } } } </code></pre> <p>Did I forget to do add some code somewhere? I'm boggled.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload