Find Wally!
Hi! I am clueless as to why my set of codes will not be displayed! could someone please offer some assistance? thank you!!!
import java.awt.*; // Font, Color, Layout managers
import javax.swing.*; // GUI components
import java.awt.event.*; // ActionEvent, ActionListener, WindowAdapter
import java.util.*;
public class weighParcel extends JFrame implements ActionListener
{
JLabel disValue = new JLabel("Please Weigh Your Parcel",JLabel.CENTER);
JLabel weightLabel, calcLabel;
JButton calcButton;
//declare variable
double cents,weight;
Random generator = new Random();
public static void main(String args[])
{weighParcel frame = new weighParcel(); }
//constructor
public void weighParcel()
{
Container c = this.getContentPane();
c.setLayout(new GridLayout(6,1));
// create logo
JLabel logoLabel = new JLabel(" ",SwingConstants.CENTER);
logoLabel.setForeground(Color.red);
logoLabel.setFont(new Font("TimesRoman", Font.ITALIC,48));
logoLabel.setText("Customer Simulation");
c.add(logoLabel); // add logo to the Frame
c.setBackground(Color.white);
weightLabel.setFont(new Font("TimesRoman", Font.ITALIC,48));
weightLabel.setForeground(Color.orange);
weightLabel.setBackground(Color.black);
calcLabel.setFont(new Font("TimesRoman", Font.ITALIC,48));
calcLabel.setForeground(Color.orange);
calcLabel.setBackground(Color.black);
c.add(weightLabel);
c.add(calcLabel);
c.add(disValue);
// create & add Buttons for bottom panel
JButton weighButton = new JButton("Weigh Parcel");
weighButton.setFont(new Font("TimesRoman", Font.ITALIC,28));
weighButton.setBackground(Color.black);
weighButton.setForeground(Color.orange);
JButton calcButton = new JButton("Calculate Postage Amount");
calcButton.setFont(new Font("TimesRoman", Font.ITALIC,28));
calcButton.setBackground(Color.black);
calcButton.setForeground(Color.orange);
JButton purchaseButton = new JButton("Purchase Postage Labels");
purchaseButton.setFont(new Font("TimesRoman", Font.ITALIC,28));
purchaseButton.setBackground(Color.black);
purchaseButton.setForeground(Color.orange);
JButton closeButton = new JButton("Close");
closeButton.setFont(new Font("TimesRoman", Font.ITALIC,28));
closeButton.setBackground(Color.white);
closeButton.setForeground(Color.pink);
c.add(weighButton);
c.add(calcButton);
c.add(purchaseButton);
c.add(closeButton);
// register frame as listener for button events
weighButton.addActionListener(this);
calcButton.addActionListener(this);
purchaseButton.addActionListener(this);
closeButton.addActionListener(this);
this.setSize(800,600);
this.setTitle("Weigh Parcel");
this.setVisible(true);
// create anonymous inner class to handle window closing event
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent event)
{shutDown();}
}
);
}
// actionPerformed is invoked when a Button is clicked
public void actionPerformed(ActionEvent e)
{// see which button was clicked
if(e.getActionCommand() == "Weigh Parcel")
{weight = generator.nextDouble();
weightLabel.setText("This Parcel Weighs" + weight + "");}
if(e.getActionCommand() == "Calculate Postage Amount")
{cents = weight * 10;
calcLabel.setText("The Amount Payable is" + Math.round(cents) + "");}
if(e.getActionCommand() == "Purchase Postage Labels")
{purchase();}
if(e.getActionCommand() == "Close")
{shutDown();}
}
private void purchase()
{
Purchase purchaseFrame = new Purchase();
purchaseFrame.setSize(800,600);
purchaseFrame.setTitle("Purchase Postage Labels");
purchaseFrame.setVisible(true);
this.dispose();
}
// return to main menu
public void shutDown()
{
CustomerSim customerSimFrame = new CustomerSim();
this.dispose();
}
}

