Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Java Help

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-02-2007, 08:26 PM
Victor Victor is offline
Learning Programmer
 
Join Date: May 2007
Posts: 96
Credits: 0
Rep Power: 6
Victor is on a distinguished road
Default 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?
Java Code:
  1. /*
  2. * GUI.java
  3. *
  4. * Created on September 29, 2007, 9:37 PM
  5. */
  6.  
  7. package nasg;
  8. import java.io.*;
  9. import java.lang.reflect.Method;
  10. import java.util.Arrays;
  11. import javax.swing.JOptionPane;
  12. import java.util.HashMap;
  13. import java.util.Map;
  14.  
  15.  
  16. /**
  17. *
  18. * @author  Victor
  19. */
  20. public class GUI{
  21.    
  22.     /** Creates new form GUI */
  23.     public GUI() {
  24.         initComponents();
  25.     }
  26.    
  27.     /** This method is called from within the constructor to
  28.      * initialize the form.
  29.      * WARNING: Do NOT modify this code. The content of this method is
  30.      * always regenerated by the Form Editor.
  31.      */
  32.     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
  33.     private void initComponents() {
  34.         jComboBox1 = new javax.swing.JComboBox();
  35.         jScrollPane1 = new javax.swing.JScrollPane();
  36.         jTextArea1 = new javax.swing.JTextArea();
  37.         jLabel1 = new javax.swing.JLabel();
  38.         jButton1 = new javax.swing.JButton();
  39.  
  40.         setTitle("Neo's Admin Script Generator 0.5");
  41.         setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
  42.         setLocationByPlatform(true);
  43.         setResizable(false);
  44.         addKeyListener(new java.awt.event.KeyAdapter() {
  45.             public void keyPressed(java.awt.event.KeyEvent evt) {
  46.                 formKeyPressed(evt);
  47.             }
  48.         });
  49.  
  50.         getAccessibleContext().setAccessibleName("nasg");
  51.         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" }));
  52.         jComboBox1.addActionListener(new java.awt.event.ActionListener() {
  53.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  54.                 jComboBox1ActionPerformed(evt);
  55.             }
  56.         });
  57.  
  58.         jTextArea1.setColumns(20);
  59.         jTextArea1.setLineWrap(true);
  60.         jTextArea1.setRows(5);
  61.         jTextArea1.setText("Enter Admin Message");
  62.         jTextArea1.setToolTipText("You can enter your administrator's message here");
  63.         jTextArea1.setWrapStyleWord(true);
  64.         jScrollPane1.setViewportView(jTextArea1);
  65.  
  66.         jLabel1.setText("Weapon Class");
  67.  
  68.         jButton1.setText("Compile!");
  69.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  70.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  71.                 jButton1ActionPerformed(evt);
  72.             }
  73.         });
  74.  
  75.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  76.         getContentPane().setLayout(layout);
  77.         layout.setHorizontalGroup(
  78.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  79.             .addGroup(layout.createSequentialGroup()
  80.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  81.                     .addGroup(layout.createSequentialGroup()
  82.                         .addGap(73, 73, 73)
  83.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  84.                             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  85.                                 .addComponent(jLabel1)
  86.                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  87.                                 .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  88.                             .addComponent(jButton1)))
  89.                     .addGroup(layout.createSequentialGroup()
  90.                         .addContainerGap(34, Short.MAX_VALUE)
  91.                         .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)))
  92.                 .addContainerGap())
  93.         );
  94.         layout.setVerticalGroup(
  95.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  96.             .addGroup(layout.createSequentialGroup()
  97.                 .addGap(23, 23, 23)
  98.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  99.                     .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  100.                     .addComponent(jLabel1))
  101.                 .addGap(23, 23, 23)
  102.                 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  103.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
  104.                 .addComponent(jButton1)
  105.                 .addContainerGap())
  106.         );
  107.         pack();
  108.     }// </editor-fold>                       
  109.    
  110.     private void formKeyPressed(java.awt.event.KeyEvent evt) {                               
  111. // TODO add your handling code here:
  112.     }                               
  113.    
  114.     private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
  115.         jComboBox1.addActionListener(new java.awt.event.ActionListener() {
  116.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  117.                 JComboBox jcmbType = (JComboBox)e.getSource();
  118.                 String cmbType = (String)jcmbType.getSelectedItem();
  119.                 jComboBox1ActionPerformed(evt);
  120.     }                                         
  121.            
  122.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
  123.         FileOutputStream fout;
  124.        
  125.         try {
  126.             fout = new FileOutputStream("nasg.txt");
  127.             for(int number = 1; number <= 50; number++) {
  128.                 new PrintStream(fout).println("admin forceclass " + cmdType);
  129.             }
  130.             new PrintStream(fout).println("admin message ");
  131.             new PrintStream(fout).println("admin say ");
  132.             fout.close();
  133.         } catch (IOException e) {
  134.             System.err.println("Unable to write to file");
  135.             System.exit(-1);
  136.         }
  137.        
  138.     }                                       
  139.    
  140.     /**
  141.      * @param args the command line arguments
  142.      */
  143.     public static void main(String args[]) {
  144.         java.awt.EventQueue.invokeLater(new Runnable() {
  145.             public void run() {
  146.                 new GUI().setVisible(true);
  147.             }
  148.         });
  149.     }
  150.     // Variables declaration - do not modify                     
  151.     private javax.swing.JButton jButton1;
  152.     private javax.swing.JComboBox jComboBox1;
  153.     private javax.swing.JLabel jLabel1;
  154.     private javax.swing.JScrollPane jScrollPane1;
  155.     private javax.swing.JTextArea jTextArea1;
  156.     // End of variables declaration
  157.  
And my error:
Quote:
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.
__________________
Pegasus Homepage

Last edited by John; 10-02-2007 at 11:08 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 10-02-2007, 11:22 PM
John's Avatar   
John John is online now
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,238
Last Blog:
Passwords
Credits: 887
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
Send a message via AIM to John Send a message via MSN to John
Default

It looks like your missing two closing braces and one closing parenthesis in this method.

Java Code:
  1. private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
  2.         jComboBox1.addActionListener(new java.awt.event.ActionListener() {
  3.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  4.                 JComboBox jcmbType = (JComboBox)e.getSource();
  5.                 String cmbType = (String)jcmbType.getSelectedItem();
  6.                 jComboBox1ActionPerformed(evt);
  7. }

Should be:

Java Code:
  1. private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
  2.         jComboBox1.addActionListener(new java.awt.event.ActionListener() {
  3.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  4.                 JComboBox jcmbType = (JComboBox)e.getSource();
  5.                 String cmbType = (String)jcmbType.getSelectedItem();
  6.                 jComboBox1ActionPerformed(evt);
  7.             }
  8.         });
  9. }

I think.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall

Last edited by John; 10-02-2007 at 11:24 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-03-2007, 08:24 PM
Victor Victor is offline
Learning Programmer
 
Join Date: May 2007
Posts: 96
Credits: 0
Rep Power: 6
Victor is on a distinguished road
Default

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?
__________________
Pegasus Homepage
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati