Here are the errors I am getting, but I can't figure it out. Please help:

GUI.java: 10: illegal start of expression

public GUI(MovieCollection i) {
   ^
GUI.java: 110: illegal start of expression
   private javax.swing.JButton extButton;
   ^
GUI.java:111: illegal start of expression
   private javax.swing.JTextArea text Area;

Here is my program:

//GUI.java
package product;
import java.text.NumberFormat;

public class GUI extends javax.swing.JFrame{
{    
    MovieCollection inventory;

    /** Creates new form GUI */
    public GUI(MovieCollection i) {
        inventory = i;
        initComponents();
        repaint();
    }

    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        nextButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        textArea = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        nextButton.setText("Next");
        nextButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextButtonActionPerformed(evt);
            }
        });

        textArea.setColumns(20);
        textArea.setEditable(false);
        textArea.setRows(5);
        jScrollPane1.setViewportView(textArea);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(nextButton)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                    .add(nextButton))
                .addContainerGap())
        );

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

    private void nextButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
        inventory.advance();
        repaint();
}                                          

    public void repaint() {

    NumberFormat moneyFormat = NumberFormat.getCurrencyInstance();

    // fetch the current Movie object to show on screen
    Movie theMovie = inventory.getCurrent();

    // get all the properties from that movie object
    String title = theMovie.getTitle();
    int number = theMovie.getNumber();
    int stock = theMovie.getQuantity();
    double price = theMovie.getPrice();
    int year = theMovie.getYear();
    double value = theMovie.getItemValue();
    double restockingFee = theMovie.getRestockingFee();

    textArea.setText("");
        textArea.append("DVD # :    "+ number + "\n");
        textArea.append("DVD Title :    "+ title + "\n");
        textArea.append("DVD Year : "+ year + "\n");
        textArea.append("# in Stock :   "+ stock + "\n");
        textArea.append("Unit Price :   "+ moneyFormat.format(price) + "\n");
        textArea.append("Inventory value:   "+ moneyFormat.format(value) + "\n");
        textArea.append("Restocking fee :   "+ moneyFormat.format(restockingFee) + "\n");
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                // new GUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton nextButton;
    private javax.swing.JTextArea textArea;
    // End of variables declaration


}
}

Recommended Answers

All 3 Replies

public class GUI extends javax.swing.JFrame{
{

= extra { = error

Thanks. When I remove the bracket I end up with 12 errors. If I place a bracket after :

import java.text.NumberFormat;
{

When I add it here, I still come up with 3 similar errors.

Indent your code so you can see which { match up with which }. Post your code here with code=java tags. Just trying different places at random will not succeed. Keep your Java syntax primer open by your side - for example there's no syntax (that I know of) that allows a { to follow an import statement. Getting more errors when you fix the brackets is not necessaril a bad thing - it may mean that the compiler is now able to get further through its compilation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.