Closed Thread
Results 1 to 7 of 7

Thread: Compilation Error

  1. #1
    Victor is offline Programmer
    Join Date
    May 2007
    Location
    The boondocks
    Posts
    116
    Rep Power
    0

    Compilation Error

    Sidewinder | Please use [php], [code] and [highlight="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: The Forum Rules.


    Alright, I'm very puzzled. I get an error on compile and I can't fix it. Any ideas?
    [highlight="Java"]/*
    * GUI.java
    *
    * Created on September 29, 2007, 9:37 PM
    */

    package nasg;
    import java.io.*;
    import java.lang.reflect.Method;
    import java.util.Arrays;
    import javax.swing.JOptionPane;
    import java.util.HashMap;
    import java.util.Map;


    /**
    *
    * @author Victor
    */
    public class GUI{

    /** Creates new form GUI */
    public GUI() {
    initComponents();
    }

    /** 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() {
    jComboBox1 = new javax.swing.JComboBox();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jLabel1 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();

    setTitle("Neo's Admin Script Generator 0.5");
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    setLocationByPlatform(true);
    setResizable(false);
    addKeyListener(new java.awt.event.KeyAdapter() {
    public void keyPressed(java.awt.event.KeyEvent evt) {
    formKeyPressed(evt);
    }
    });

    getAccessibleContext().setAccessibleName("nasg");
    jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "r", "m", "m4m", "m4a1auto", "ma", "ar", "g", "at4", "s", "s82", "s24", "spr", "m9", "b", "sf", "ak", "ak74su", "gp", "rpg", "rpk", "svd", "mos", "v", "d", "pso", "bdm" }));
    jComboBox1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jComboBox1ActionPerformed(evt);
    }
    });

    jTextArea1.setColumns(20);
    jTextArea1.setLineWrap(true);
    jTextArea1.setRows(5);
    jTextArea1.setText("Enter Admin Message");
    jTextArea1.setToolTipText("You can enter your administrator's message here");
    jTextArea1.setWrapStyleWord(true);
    jScrollPane1.setViewportView(jTextArea1);

    jLabel1.setText("Weapon Class");

    jButton1.setText("Compile!");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addGroup(layout.createSequentialGroup()
    .addGap(73, 73, 73)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addComponent(jLabel1)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addComponent(jButton1)))
    .addGroup(layout.createSequentialGroup()
    .addContainerGap(34, Short.MAX_VALUE)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addContainerGap())
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(23, 23, 23)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jLabel1))
    .addGap(23, 23, 23)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 31, Short.MAX_VALUE)
    .addComponent(jButton1)
    .addContainerGap())
    );
    pack();
    }// </editor-fold>

    private void formKeyPressed(java.awt.event.KeyEvent evt) {
    // TODO add your handling code here:
    }

    private void jComboBox1ActionPerformed(java.awt.event.ActionEve nt evt) {
    jComboBox1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    JComboBox jcmbType = (JComboBox)e.getSource();
    String cmbType = (String)jcmbType.getSelectedItem();
    jComboBox1ActionPerformed(evt);
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    FileOutputStream fout;

    try {
    fout = new FileOutputStream("nasg.txt");
    for(int number = 1; number <= 50; number++) {
    new PrintStream(fout).println("admin forceclass " + cmdType);
    }
    new PrintStream(fout).println("admin message ");
    new PrintStream(fout).println("admin say ");
    fout.close();
    } catch (IOException e) {
    System.err.println("Unable to write to file");
    System.exit(-1);
    }

    }

    /**
    * @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.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration
    [/highlight]
    And my error:
    init:
    deps-jar:
    Compiling 1 source file to C:\Documents and Settings\Victor\My Documents\Java\NASG\build\classes
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:155: reached end of file while parsing
    private javax.swing.JTextArea jTextArea1;
    1 error
    BUILD FAILED (total time: 1 second)
    Sidewinder | Please use [php], [code] and [highlight="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: The Forum Rules.
    Last edited by John; 10-02-2007 at 09:08 PM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    It looks like your missing two closing braces and one closing parenthesis in this method.

    [HIGHLIGHT="Java"] private void jComboBox1ActionPerformed(java.awt.event.ActionEve nt evt) {
    jComboBox1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    JComboBox jcmbType = (JComboBox)e.getSource();
    String cmbType = (String)jcmbType.getSelectedItem();
    jComboBox1ActionPerformed(evt);
    } [/HIGHLIGHT]

    Should be:

    [HIGHLIGHT="Java"]private void jComboBox1ActionPerformed(java.awt.event.ActionEve nt evt) {
    jComboBox1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    JComboBox jcmbType = (JComboBox)e.getSource();
    String cmbType = (String)jcmbType.getSelectedItem();
    jComboBox1ActionPerformed(evt);
    }
    });
    } [/HIGHLIGHT]

    I think.
    Last edited by John; 10-02-2007 at 09:24 PM.

  4. #3
    Victor is offline Programmer
    Join Date
    May 2007
    Location
    The boondocks
    Posts
    116
    Rep Power
    0
    Still not working, I get 13 errors now.
    Code:
    init:
    deps-jar:
    Compiling 1 source file to C:\Documents and Settings\Victor\My Documents\Java\NASG\build\classes
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:41: cannot find symbol
    symbol  : method setDefaultCloseOperation(int)
    location: class nasg.GUI
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:42: cannot find symbol
    symbol  : method setTitle(java.lang.String)
    location: class nasg.GUI
            setTitle("NASG 0.5 Alpha");
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:43: cannot find symbol
    symbol  : method setCursor(java.awt.Cursor)
    location: class nasg.GUI
            setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:44: cannot find symbol
    symbol  : method addFocusListener(<anonymous java.awt.event.FocusAdapter>)
    location: class nasg.GUI
            addFocusListener(new java.awt.event.FocusAdapter() {
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:49: cannot find symbol
    symbol  : method addKeyListener(<anonymous java.awt.event.KeyAdapter>)
    location: class nasg.GUI
            addKeyListener(new java.awt.event.KeyAdapter() {
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:55: cannot find symbol
    symbol  : method getAccessibleContext()
    location: class nasg.GUI
            getAccessibleContext().setAccessibleName("nasg");
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:94: cannot find symbol
    symbol  : method getContentPane()
    location: class nasg.GUI
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:95: cannot find symbol
    symbol  : method getContentPane()
    location: class nasg.GUI
            getContentPane().setLayout(layout);
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:134: cannot find symbol
    symbol  : method pack()
    location: class nasg.GUI
            pack();
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:156: cannot find symbol
    symbol: class JComboBox
                    JComboBox jcmbType = (JComboBox)e.getSource();
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:156: cannot find symbol
    symbol: class JComboBox
                    JComboBox jcmbType = (JComboBox)e.getSource();
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:156: cannot find symbol
    symbol: variable e
                    JComboBox jcmbType = (JComboBox)e.getSource();
    C:\Documents and Settings\Victor\My Documents\Java\NASG\src\nasg\GUI.java:187: cannot find symbol
    symbol  : method setVisible(boolean)
    location: class nasg.GUI
                    new GUI().setVisible(true);
    13 errors
    BUILD FAILED (total time: 0 seconds)
    Am I missing a declaration maybe?

  5. #4
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    Do you use an IDE? You should really try out Eclipse.

    I just put your code into my Eclipse and it has more than those 13 errors.

    First off, in your initComponents() method there are several methods that aren't called on an object. Meaning, you never created a JFrame/Applet so you cant call the setTitle, setCursor, setLocationByPlatform methods on nothing.

    Second, you declare your "global" variables [jButton1, jComboBox1, ect...] at the end of the class - they should be declared before they are used.

    Third, it doesn't look like your class is actually closed.

    Fourth, there are some type mismatches.

    Like I said, just pop your code into eclipse and your screen will light up with red errors.

  6. #5
    Victor is offline Programmer
    Join Date
    May 2007
    Location
    The boondocks
    Posts
    116
    Rep Power
    0
    I use NetBeans and it is supposed to do the class, and the guts of the GUI by it self, I can't edit it. But I'll try out Eclipse

  7. #6
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    I never used NetBeans. I tend to try and stay away from program's that "do it" for you, that way when you are presented with a problem like this, you aren't clueless. I wasn't going to say anything about the code because I don't to criticize other developers, especially if they are new, but a lot of the code just seems backwards.

    I've taken three college classes on Java and I have never seen variable deceleration at the end of the class. I don't know if thats a beans thing, but I makes no sense.

    I've written several tutorials on building GUI's in the tutorials section, if you have any questions, feel free to post there.

  8. #7
    Victor is offline Programmer
    Join Date
    May 2007
    Location
    The boondocks
    Posts
    116
    Rep Power
    0
    It must be a NetBeans thing, b/c the only code I actually put in myself was the action events (not sure if right terminology). Everything else I just went to design. Even the class, NetBeans setup that up when I made the project. Alot of the script, NetBeans doesn't even let me edit, especially in the guts of the GUI, I can't edit it. Which is why I was so puzzled in the first place, NetBeans was supposed to take care of it. I'm going to try out Eclipse, looks pretty solid but I've haven't downloaded it yet. Thanks for all your help sidewinder!

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. compilation error
    By eman ahmed in forum Java Help
    Replies: 5
    Last Post: 09-30-2010, 09:01 AM
  2. Compilation Error: Pairs and xutility
    By cod3b3ast in forum C and C++
    Replies: 5
    Last Post: 04-16-2010, 02:29 PM
  3. Compilation error
    By nagarjuna02 in forum C# Programming
    Replies: 2
    Last Post: 02-08-2010, 05:24 AM
  4. G++ Compilation Error Doesn't Make Sense
    By deltatux in forum C and C++
    Replies: 8
    Last Post: 02-19-2009, 02:17 PM
  5. c++/cli - irritating compilation error
    By jwa in forum Managed C++
    Replies: 2
    Last Post: 01-20-2008, 06:43 PM

Tags for this Thread

Bookmarks

Posting Permissions

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