Results 1 to 5 of 5

Thread: Error message.

  1. #1
    dean343 is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default Error message.

    Hi, I am new to programming and am confused on the error message that I am getting. I am going to post t error message below and the code. Please help if possible.
    Thanks
    Also know it is very long, but not sure how to put it all up here.

    Error message: only appears when I hit the calculate button on my GUI
    Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "$450.00"
    at sun.misc.FloatingDecimal.readJavaFormatString(Floa tingDecimal.java:1241)
    at java.lang.Double.parseDouble(Double.java:540)
    at Glassware.GlasswareGUI.calculateJButtonActionPerfo rmed(GlasswareGUI.java:477)
    at Glassware.GlasswareGUI.access$300(GlasswareGUI.jav a:26)
    at Glassware.GlasswareGUI$4.actionPerformed(Glassware GUI.java:198)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.jav a:6505)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3321)
    at java.awt.Component.processEvent(Component.java:627 0)
    at java.awt.Container.processEvent(Container.java:222 9)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4861)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
    at java.awt.Component.dispatchEvent(Component.java:46 87)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719 )
    at java.awt.Component.dispatchEvent(Component.java:46 87)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:723)
    at java.awt.EventQueue.access$200(EventQueue.java:103 )
    at java.awt.EventQueue$3.run(EventQueue.java:682)
    at java.awt.EventQueue$3.run(EventQueue.java:680)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:696)
    at java.awt.EventQueue$4.run(EventQueue.java:694)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 693)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:91)


    Code:
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package Glassware;

    import java.awt.Color;
    import java.awt.Container;
    import java.awt.Toolkit;
    import java.awt.event.ActionListener;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import javax.swing.JFormattedTextField;
    import javax.swing.JSpinner;
    import javax.swing.JSpinner.DefaultEditor;
    import javax.swing.SpinnerNumberModel;


    /**
    *

    * @author Dean
    */
    public class GlasswareGUI extends javax.swing.JFrame {
    DecimalFormat dollars = new DecimalFormat("$#,##0.00");
    final double aprice = 225.00;
    final double bprice = 185.00;
    final double gprice = 155.00;
    final double tax_rate = 0.098;
    /**
    * Creates new form GlasswareGUI
    */
    public GlasswareGUI() {
    initComponents();
    setLocationRelativeTo(null); //sets form centered
    this.setIconImage(Toolkit.getDefaultToolkit().getI mage("src/icon.jpg")); //sets icon image
    this.getRootPane().setDefaultButton(calculateJButt on); //sets calculate button as default
    Container container = this.getContentPane(); //set frame background color
    container.setBackground(Color.GRAY); //choose color
    alphaJSpinner.requestFocus();
    setDate();
    // Disable keyboard edits in the spinner
    JFormattedTextField as = ((JSpinner.DefaultEditor) alphaJSpinner.getEditor()).getTextField();
    as.setEditable(false);
    as.setBackground(Color.white);
    JFormattedTextField bs = ((JSpinner.DefaultEditor) betaJSpinner.getEditor()).getTextField();
    bs.setEditable(false);
    bs.setBackground(Color.white);
    JFormattedTextField gs = ((JSpinner.DefaultEditor) gammaJSpinner.getEditor()).getTextField();
    gs.setEditable(false);
    gs.setBackground(Color.white);


    }
    /**
    * Description
    * @see import java.text.SimpleDateFormat;
    * @see import java.util.Date;
    * @author Dean Freundlich
    * date 1/16/2013
    * Description Puts the current date in the title bar for each time the GUI i opened.
    */
    private void setDate()
    {
    SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/YYYY");
    Date date = new Date();
    this.setTitle("Sara's Glassware--" + dateFormat.format(date));
    }


    /**
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    titleJTextField = new javax.swing.JTextField();
    invoiceJTextField = new javax.swing.JTextField();
    artJLabel = new javax.swing.JLabel();
    quantityJLabel = new javax.swing.JLabel();
    priceJLabel = new javax.swing.JLabel();
    extendedJLabel = new javax.swing.JLabel();
    alphaJSpinner = new javax.swing.JSpinner();
    betaJSpinner = new javax.swing.JSpinner();
    gammaJSpinner = new javax.swing.JSpinner();
    alpha$JLabel = new javax.swing.JLabel();
    beta$JLabel = new javax.swing.JLabel();
    gamma$JLabel = new javax.swing.JLabel();
    apriceJLabel = new javax.swing.JLabel();
    bpriceLabel = new javax.swing.JLabel();
    gpriceJLabel = new javax.swing.JLabel();
    iconJLabel = new javax.swing.JLabel();
    calculateJButton = new javax.swing.JButton();
    quitJButton = new javax.swing.JButton();
    clearJButton = new javax.swing.JButton();
    subJLabel = new javax.swing.JLabel();
    taxJLabel = new javax.swing.JLabel();
    totalJLabel = new javax.swing.JLabel();
    bartJLabel = new javax.swing.JLabel();
    gartJLabel = new javax.swing.JLabel();
    aartJLabel = new javax.swing.JLabel();
    invoicenumberJLabel = new javax.swing.JLabel();
    atotalJTextField = new javax.swing.JTextField();
    btotalJTextField = new javax.swing.JTextField();
    gtotalJTextField = new javax.swing.JTextField();
    subJTextField = new javax.swing.JTextField();
    finaltotalJTextField = new javax.swing.JTextField();
    taxJTextField = new javax.swing.JTextField();
    glasswareJMenuBar = new javax.swing.JMenuBar();
    fileJMenu = new javax.swing.JMenu();
    clearJMenuItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JPopupMenu.Separator();
    quitJMenuItem = new javax.swing.JMenuItem();
    actionJMenu = new javax.swing.JMenu();
    calculateJMenuItem = new javax.swing.JMenuItem();
    HelpJMenu = new javax.swing.JMenu();
    AboutJMenuItem = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
    setTitle("Sara's Glassware");
    setResizable(false);

    titleJTextField.setEditable(false);
    titleJTextField.setBackground(new java.awt.Color(255, 255, 204));
    titleJTextField.setFont(new java.awt.Font("SansSerif", 0, 18)); // NOI18N
    titleJTextField.setText("Sara's Glass Works Invoice");
    titleJTextField.setToolTipText("A privately owned company that specializes in table decorative glassware. The company started on love for the art and has continued that way since 1998.");

    invoiceJTextField.setEditable(false);
    invoiceJTextField.setBackground(new java.awt.Color(255, 255, 204));
    invoiceJTextField.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    invoiceJTextField.setText("Invoice Number");

    artJLabel.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    artJLabel.setText("Art Piece");

    quantityJLabel.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    quantityJLabel.setText("Quantity");

    priceJLabel.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    priceJLabel.setText("Price");

    extendedJLabel.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    extendedJLabel.setText("Extended Total");

    alphaJSpinner.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    alphaJSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
    public void stateChanged(javax.swing.event.ChangeEvent evt) {
    alphaJSpinnerStateChanged(evt);
    }
    });

    betaJSpinner.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    betaJSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
    public void stateChanged(javax.swing.event.ChangeEvent evt) {
    betaJSpinnerStateChanged(evt);
    }
    });

    gammaJSpinner.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    gammaJSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
    public void stateChanged(javax.swing.event.ChangeEvent evt) {
    gammaJSpinnerStateChanged(evt);
    }
    });

    alpha$JLabel.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    alpha$JLabel.setText("$");

    beta$JLabel.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    beta$JLabel.setText("$");

    gamma$JLabel.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    gamma$JLabel.setText("$");

    apriceJLabel.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    apriceJLabel.setText("225.00");

    bpriceLabel.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    bpriceLabel.setText("185.00");

    gpriceJLabel.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
    gpriceJLabel.setText("155.00");

    iconJLabel.setIcon(new javax.swing.ImageIcon("C:\\Users\\Dean\\Documents\ \NetBeansProjects\\Project1\\src\\icon.jpg")); // NOI18N

    calculateJButton.setBackground(new java.awt.Color(255, 255, 204));
    calculateJButton.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    calculateJButton.setMnemonic('c');
    calculateJButton.setText("Calculate");
    calculateJButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    calculateJButtonActionPerformed(evt);
    }
    });

    quitJButton.setBackground(new java.awt.Color(255, 255, 204));
    quitJButton.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    quitJButton.setMnemonic('q');
    quitJButton.setText("Quit");
    quitJButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    quitJButtonActionPerformed(evt);
    }
    });

    clearJButton.setBackground(new java.awt.Color(255, 255, 204));
    clearJButton.setMnemonic('x');
    clearJButton.setText("Clear");
    clearJButton.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    clearJButtonActionPerformed(evt);
    }
    });

    subJLabel.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    subJLabel.setText("Sub Total:");

    taxJLabel.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    taxJLabel.setText("Tax:");

    totalJLabel.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
    totalJLabel.setText("Total:");

    bartJLabel.setIcon(new javax.swing.ImageIcon("C:\\Users\\Dean\\Documents\ \NetBeansProjects\\Project1\\src\\85-th.jpg")); // NOI18N
    bartJLabel.setToolTipText("A small vase centerpiece perfect for floating flowers or candles. With warm colors it sets the mood perfectly. Only 20 left");

    gartJLabel.setIcon(new javax.swing.ImageIcon("C:\\Users\\Dean\\Documents\ \NetBeansProjects\\Project1\\src\\2.jpg")); // NOI18N
    gartJLabel.setToolTipText("Either runner table decorations or perfect for an out door gardn. This piece offers balance and tranquility upon its resting place. Selling fast, only 6 left!!");

    aartJLabel.setIcon(new javax.swing.ImageIcon("C:\\Users\\Dean\\Documents\ \NetBeansProjects\\Project1\\src\\AG-139.1T.jpg")); // NOI18N
    aartJLabel.setToolTipText("A decorative table piece, that is focused on the sea with intricate interior designs. Only ten left");

    invoicenumberJLabel.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N

    atotalJTextField.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N

    btotalJTextField.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N

    gtotalJTextField.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N

    subJTextField.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N

    finaltotalJTextField.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N

    taxJTextField.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N

    fileJMenu.setText("File");

    clearJMenuItem.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    clearJMenuItem.setMnemonic('x');
    clearJMenuItem.setText("Clear");
    fileJMenu.add(clearJMenuItem);
    fileJMenu.add(jSeparator1);

    quitJMenuItem.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    quitJMenuItem.setMnemonic('q');
    quitJMenuItem.setText("Quit");
    quitJMenuItem.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    quitJMenuItemActionPerformed(evt);
    }
    });
    fileJMenu.add(quitJMenuItem);

    glasswareJMenuBar.add(fileJMenu);

    actionJMenu.setText("Action");

    calculateJMenuItem.setMnemonic('c');
    calculateJMenuItem.setText("Calculate");
    actionJMenu.add(calculateJMenuItem);

    glasswareJMenuBar.add(actionJMenu);

    HelpJMenu.setText("Help");

    AboutJMenuItem.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
    AboutJMenuItem.setMnemonic('a');
    AboutJMenuItem.setText("About");
    HelpJMenu.add(AboutJMenuItem);

    glasswareJMenuBar.add(HelpJMenu);

    setJMenuBar(glasswareJMenuBar);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(invoiceJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(gartJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createSequentialGroup()
    .addGap(15, 15, 15)
    .addComponent(iconJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addComponent(bartJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addGroup(layout.createSequentialGroup()
    .addGap(28, 28, 28)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(aartJLabel)
    .addComponent(artJLabel))))
    .addGap(18, 18, Short.MAX_VALUE)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(alphaJSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(betaJSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(gammaJSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(18, 18, 18)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(alpha$JLabel)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(priceJLabel)
    .addComponent(apriceJLabel)))
    .addGroup(layout.createSequentialGroup()
    .addComponent(gamma$JLabel)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(bpriceLabel))
    .addGroup(layout.createSequentialGroup()
    .addComponent(beta$JLabel)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(gpriceJLabel))))
    .addGroup(layout.createSequentialGroup()
    .addGap(61, 61, 61)
    .addComponent(totalJLabel)))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 47, Short.MAX_VALUE)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(extendedJLabel)
    .addComponent(atotalJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(btotalJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.TRAILING, false)
    .addComponent(taxJTextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
    .addComponent(finaltotalJTextField, javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(subJTextField, javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(gtotalJTextField, javax.swing.GroupLayout.Alignment.LEADING)))
    .addGap(45, 45, 45))
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(titleJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(quantityJLabel)
    .addComponent(invoicenumberJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_S IZE, Short.MAX_VALUE))))
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addComponent(calculateJButton, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createSequentialGroup()
    .addComponent(quitJButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(clearJButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
    .addGap(33, 33, 33)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(subJLabel)
    .addComponent(taxJLabel))
    .addContainerGap())
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(iconJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createSequentialGroup()
    .addGap(12, 12, 12)
    .addComponent(titleJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addComponent(invoiceJTextField)
    .addComponent(invoicenumberJLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(artJLabel)
    .addComponent(quantityJLabel)
    .addComponent(priceJLabel)
    .addComponent(extendedJLabel))
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(51, 51, 51)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(alphaJSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(alpha$JLabel)
    .addComponent(apriceJLabel)
    .addComponent(atotalJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addGroup(layout.createSequentialGroup()
    .addGap(35, 35, 35)
    .addComponent(aartJLabel)))
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addGroup(layout.createSequentialGroup()
    .addGap(41, 41, 41)
    .addComponent(bartJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(49, 49, 49)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.TRAILING)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(gammaJSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(beta$JLabel)
    .addComponent(gpriceJLabel))
    .addComponent(gartJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addGroup(layout.createSequentialGroup()
    .addGap(66, 66, 66)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(betaJSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(gamma$JLabel)
    .addComponent(bpriceLabel)
    .addComponent(btotalJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(gtotalJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)))
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(calculateJButton, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(9, 9, 9)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.TRAILING, false)
    .addComponent(quitJButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(clearJButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(subJLabel)
    .addComponent(subJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.TRAILING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(taxJLabel)
    .addComponent(taxJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(totalJLabel))
    .addComponent(finaltotalJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_S IZE, Short.MAX_VALUE))
    );

    alphaJSpinner.setModel(new SpinnerNumberModel(0, 0, 10, 1));
    betaJSpinner.setModel(new SpinnerNumberModel(0, 0, 20, 1));
    gammaJSpinner.setModel(new SpinnerNumberModel(0, 0, 6, 1));

    pack();
    }// </editor-fold>

    private void quitJButtonActionPerformed(java.awt.event.ActionEv ent evt) {
    System.exit(0);
    }

    private void clearJButtonActionPerformed(java.awt.event.ActionE vent evt) {
    alphaJSpinner.setValue(0);
    betaJSpinner.setValue(0);
    gammaJSpinner.setValue(0);
    atotalJTextField.setText("");
    btotalJTextField.setText("");
    gtotalJTextField.setText("");
    finaltotalJTextField.setText("");
    taxJLabel.setText("");
    subJTextField.setText("");

    }

    private void quitJMenuItemActionPerformed(java.awt.event.Action Event evt) {
    System.exit(0);
    }

    private void calculateJButtonActionPerformed(java.awt.event.Act ionEvent evt) {

    double alpha = Double.parseDouble(atotalJTextField.getText().toSt ring());
    double beta = Double.parseDouble(btotalJTextField.getText().toSt ring());
    double gamma = Double.parseDouble(gtotalJTextField.getText().toSt ring());
    double sub = alpha + beta + gamma;

    subJTextField.setText(dollars.format(sub));

    double tax = sub * tax_rate;
    taxJTextField.setText(dollars.format(tax));

    double total = sub + tax;
    finaltotalJTextField.setText(dollars.format(total) );



    }

    private void betaJSpinnerStateChanged(javax.swing.event.ChangeE vent evt) {
    byte beta = Byte.parseByte(betaJSpinner.getValue().toString()) ;
    double btotal = beta * bprice;

    btotalJTextField.setText(dollars.format(btotal));

    }

    private void alphaJSpinnerStateChanged(javax.swing.event.Change Event evt) {
    byte alpha = Byte.parseByte(alphaJSpinner.getValue().toString() );
    double atotal = alpha * aprice;

    atotalJTextField.setText(dollars.format(atotal));
    }

    private void gammaJSpinnerStateChanged(javax.swing.event.Change Event evt) {
    byte gamma = Byte.parseByte(gammaJSpinner.getValue().toString() );
    double gtotal = gamma * gprice;

    gtotalJTextField.setText(dollars.format(gtotal));
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    * For details see How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)
    */
    try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if ("Nimbus".equals(info.getName())) {
    javax.swing.UIManager.setLookAndFeel(info.getClass Name());
    break;
    }
    }
    } catch (ClassNotFoundException ex) {
    java.util.logging.Logger.getLogger(GlasswareGUI.cl ass.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    java.util.logging.Logger.getLogger(GlasswareGUI.cl ass.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    java.util.logging.Logger.getLogger(GlasswareGUI.cl ass.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(GlasswareGUI.cl ass.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new GlasswareGUI().setVisible(true);
    }
    });
    }
    // Variables declaration - do not modify
    private javax.swing.JMenuItem AboutJMenuItem;
    private javax.swing.JMenu HelpJMenu;
    private javax.swing.JLabel aartJLabel;
    private javax.swing.JMenu actionJMenu;
    private javax.swing.JLabel alpha$JLabel;
    private javax.swing.JSpinner alphaJSpinner;
    private javax.swing.JLabel apriceJLabel;
    private javax.swing.JLabel artJLabel;
    private javax.swing.JTextField atotalJTextField;
    private javax.swing.JLabel bartJLabel;
    private javax.swing.JLabel beta$JLabel;
    private javax.swing.JSpinner betaJSpinner;
    private javax.swing.JLabel bpriceLabel;
    private javax.swing.JTextField btotalJTextField;
    private javax.swing.JButton calculateJButton;
    private javax.swing.JMenuItem calculateJMenuItem;
    private javax.swing.JButton clearJButton;
    private javax.swing.JMenuItem clearJMenuItem;
    private javax.swing.JLabel extendedJLabel;
    private javax.swing.JMenu fileJMenu;
    private javax.swing.JTextField finaltotalJTextField;
    private javax.swing.JLabel gamma$JLabel;
    private javax.swing.JSpinner gammaJSpinner;
    private javax.swing.JLabel gartJLabel;
    private javax.swing.JMenuBar glasswareJMenuBar;
    private javax.swing.JLabel gpriceJLabel;
    private javax.swing.JTextField gtotalJTextField;
    private javax.swing.JLabel iconJLabel;
    private javax.swing.JTextField invoiceJTextField;
    private javax.swing.JLabel invoicenumberJLabel;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JLabel priceJLabel;
    private javax.swing.JLabel quantityJLabel;
    private javax.swing.JButton quitJButton;
    private javax.swing.JMenuItem quitJMenuItem;
    private javax.swing.JLabel subJLabel;
    private javax.swing.JTextField subJTextField;
    private javax.swing.JLabel taxJLabel;
    private javax.swing.JTextField taxJTextField;
    private javax.swing.JTextField titleJTextField;
    private javax.swing.JLabel totalJLabel;
    // End of variables declaration
    }

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

    Default Re: Error message.

    You get this error because "$450.00" can`t be parsed to a Double with Double.parseToDouble....

    OT:
    new SimpleDateFormat("MM/dd/YYYY"); -> "Y" is not a valid character -> "y"

  3. #3
    jairoh_ is offline Member
    Join Date
    Feb 2012
    Posts
    22
    Rep Power
    0

    Default Re: Error message.

    pls put it in code tag :(

  4. #4
    dean343 is offline Member
    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Default Re: Error message.

    How do I put it into code tag?
    new to this whole thing

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

    Default Re: Error message.

    For use of [code] [/code] tags, please read my signature link at the bottom. In essence, when posting code here, wrap the tags that I've shown around your code:

    [code]
    // ..... your code goes here
    [/code]

    Also, if you want to parse Strings that display numbers with currency symbols, then use a NumberFormat currency instance object. This is obtained via NumberFormat.getCurrencyInstance().

Similar Threads

  1. help me with this error message
    By joel7 in forum New To Java
    Replies: 1
    Last Post: 11-27-2012, 08:10 AM
  2. Need help with error message!
    By cstampar in forum New To Java
    Replies: 2
    Last Post: 12-04-2011, 07:52 PM
  3. 'else' without 'if' error message
    By jim01 in forum New To Java
    Replies: 6
    Last Post: 04-22-2011, 09:10 PM
  4. Error Message????
    By Cubba27 in forum New To Java
    Replies: 11
    Last Post: 11-21-2009, 02:46 PM

Posting Permissions

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