Results 1 to 6 of 6
  1. #1
    JBeese is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default New to Java, cant figure out why im getting this error code.

    import java.awt.*;
    import javax.swing.*;
    import java.text.*;
    import java.awt.event.*;


    public class RetailSales extends JFrame
    {
    /* --------------------------------- declarations */

    // color objects
    Color black = new Color(0, 0, 0);
    Color white = new Color(255, 255, 255);

    // number formats
    DecimalFormat currency; // declaration statement


    // components
    JLabel numberOfItemsJLabel;
    JTextField numberOfItemsJTextField;

    JLabel priceOfItemsJLabel;
    JTextField priceOfItemsJTextField;

    JLabel subTotalJLabel;
    JTextField subTotalJTextField;

    JLabel salesTaxJLabel;
    JTextField salesTaxJTextField;

    JLabel totalAmountJLabel;
    JTextField totalAmountJTextField;

    JButton enterJButton;

    JButton clearJButton;



    // variables - constants

    int numberOfItems;
    double priceOfItems;
    double subTotal;
    double totalAmount;
    double salesTax;




    public RetailSales()
    {
    createUserInterface();
    }

    public void createUserInterface()
    {
    Container contentPane = getContentPane();
    contentPane.setBackground(white);
    contentPane.setLayout(null);

    //initialize components
    currency = new DecimalFormat("$0.00");

    numberOfItemsJLabel = new JLabel();
    numberOfItemsJLabel.setBounds(75, 50, 100, 20);
    numberOfItemsJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    numberOfItemsJLabel.setText("Number Of Items:");
    numberOfItemsJLabel.setForeground(black);
    numberOfItemsJLabel.setHorizontalAlignment(JLabel. CENTER);
    contentPane.add(numberOfItemsJLabel);

    numberOfItemsJTextField = new JTextField();
    numberOfItemsJTextField.setBounds(225, 50, 50, 20);
    numberOfItemsJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    numberOfItemsJTextField.setHorizontalAlignment(JTe xtField.CENTER);
    numberOfItemsJTextField.setForeground(black);
    numberOfItemsJTextField.setBackground(white);
    numberOfItemsJTextField.setEditable(true);
    contentPane.add(numberOfItemsJTextField);

    priceOfItemsJLabel = new JLabel();
    priceOfItemsJLabel.setBounds(75, 80, 100, 20);
    priceOfItemsJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    priceOfItemsJLabel.setText("Price Per Item:");
    priceOfItemsJLabel.setForeground(black);
    priceOfItemsJLabel.setHorizontalAlignment(JLabel.L EFT);
    contentPane.add(priceOfItemsJLabel);

    priceOfItemsJTextField = new JTextField();
    priceOfItemsJTextField.setBounds(225, 80, 50, 20);
    priceOfItemsJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    priceOfItemsJTextField.setHorizontalAlignment(JTex tField.CENTER);
    priceOfItemsJTextField.setForeground(black);
    priceOfItemsJTextField.setBackground(white);
    priceOfItemsJTextField.setEditable(true);
    contentPane.add(priceOfItemsJTextField);

    subTotalJLabel = new JLabel();
    subTotalJLabel.setBounds(75, 130, 100, 20);
    subTotalJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    subTotalJLabel.setText("Result Number:");
    subTotalJLabel.setForeground(black);
    subTotalJLabel.setHorizontalAlignment(JLabel.LEFT) ;
    contentPane.add(subTotalJLabel);

    subTotalJTextField = new JTextField();
    subTotalJTextField.setBounds(225, 130, 50, 20);
    subTotalJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    subTotalJTextField.setHorizontalAlignment(JTextFie ld.CENTER);
    subTotalJTextField.setForeground(black);
    subTotalJTextField.setBackground(white);
    subTotalJTextField.setEditable(false);
    contentPane.add(subTotalJTextField);

    salesTaxJLabel = new JLabel();
    salesTaxJLabel.setBounds(75, 160, 100, 20);
    salesTaxJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    salesTaxJLabel.setText("Sales Tax:");
    salesTaxJLabel.setForeground(black);
    salesTaxJLabel.setHorizontalAlignment(JLabel.LEFT) ;
    contentPane.add(salesTaxJLabel);

    salesTaxJTextField = new JTextField();
    salesTaxJTextField.setBounds(225, 160, 50, 20);
    salesTaxJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    salesTaxJTextField.setHorizontalAlignment(JTextFie ld.CENTER);
    salesTaxJTextField.setForeground(black);
    salesTaxJTextField.setBackground(white);
    salesTaxJTextField.setEditable(false);
    contentPane.add(salesTaxJTextField);

    totalAmountJLabel = new JLabel();
    totalAmountJLabel.setBounds(75, 190, 100, 20);
    totalAmountJLabel.setFont(new Font("Default", Font.PLAIN, 12));
    totalAmountJLabel.setText("Total Amount:");
    totalAmountJLabel.setForeground(black);
    totalAmountJLabel.setHorizontalAlignment(JLabel.LE FT);
    contentPane.add(totalAmountJLabel);

    totalAmountJTextField = new JTextField();
    totalAmountJTextField.setBounds(225, 190, 50, 20);
    totalAmountJTextField.setFont(new Font("Default", Font.PLAIN, 12));
    totalAmountJTextField.setHorizontalAlignment(JText Field.CENTER);
    totalAmountJTextField.setForeground(black);
    totalAmountJTextField.setBackground(white);
    totalAmountJTextField.setEditable(false);
    contentPane.add(totalAmountJTextField);

    enterJButton = new JButton();
    enterJButton.setBounds(150, 300, 50, 20);
    enterJButton.setFont(new Font("Default", Font.PLAIN, 12));
    enterJButton.setText("Enter");
    enterJButton.setForeground(black);
    enterJButton.setBackground(white);
    contentPane.add(enterJButton);
    enterJButton.addActionListener(

    new ActionListener()
    {
    public void actionPerformed(ActionEvent event)
    {
    enterJButtonActionPerformed(event);
    }
    }
    );




    // set properties of application’s window
    setTitle("RetailSales");
    setSize(400, 400);
    setVisible(true);
    }

    // main method
    public static void main(String[] args)
    {
    RetailSales application = new RetailSales();
    application.setDefaultCloseOperation(JFrame.EXIT_O N_CLOSE);

    }

    }







    // when i compile i get this error message.

    RetailSales.java:171: cannot find symbol
    symbol: method enterJButtonActionPerformed(java.awt.event.ActionE vent)
    enterJButtonActionPerformed(event);
    ^


    This is my 3rd assignment in an online college course, I haven't even gotten to hard part yet of writing the main method and the assignment is due in 2 days. I dont think anything has ever made me so frustrated as this programing stuff gets me.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    There is no enterJButtonActionPerformed method in your code!
    You have to write a method !

    public void enterJButtonActionPerformed(ActionEvent event){
    ......
    }

    ?!

  3. #3
    JBeese is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    oh ok, so as I go through and write the method for the calculations and what not that error will go away? Thanks

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by JBeese View Post
    oh ok, so as I go through and write the method for the calculations and what not that error will go away? Thanks
    It would be quicker to try this and see what happens rather than ask us here.

  5. #5
    JBeese is offline Member
    Join Date
    Jun 2011
    Posts
    10
    Rep Power
    0

    Default

    sorry for fubarable, I honestly had no idea that going through and writing more could fix an error message at the top. I'm taking an online class and the course materials are a little less than helpful. I feel like im teaching myself without knowing what i need to learn or how to go about learning it. Again i apologize for any ignorance i demonstrate, im pretty lost with all of this.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by JBeese View Post
    sorry for fubarable, I honestly had no idea that going through and writing more could fix an error message at the top. I'm taking an online class and the course materials are a little less than helpful.
    You might want to take advantage of the many resources that are available on the web including the Oracle Java tutorials which you can find here: Oracle Java Tutorials


    I feel like im teaching myself without knowing what i need to learn or how to go about learning it. Again i apologize for any ignorance i demonstrate, im pretty lost with all of this.
    You weren't being criticized for your ignorance, we all must start with no knowledge, but rather for not showing us the fruits of your efforts. It's always better to try a solution first before asking here. As to teaching yourself Java, I'll wager that 95% of the folks on this site learned Java this way, me included, and so you're in good company.

Similar Threads

  1. Cannot figure out error messages
    By Teclis in forum New To Java
    Replies: 6
    Last Post: 03-29-2011, 10:31 PM
  2. Can someone figure out this error for me
    By Dev23 in forum New To Java
    Replies: 2
    Last Post: 02-24-2011, 05:31 AM
  3. Replies: 7
    Last Post: 11-04-2010, 05:10 PM
  4. Basic Java applet error, cant figure it out!
    By alacn in forum Java Applets
    Replies: 3
    Last Post: 08-03-2010, 07:25 PM
  5. Replies: 3
    Last Post: 01-11-2010, 07:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •