Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 17 of 17

Thread: ok i have tried everything but identifier expected keeps popping up!

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    44
    My Mood
    Mad
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation ok i have tried everything but identifier expected keeps popping up!

    package match.bonus.calculator;
     
    import java.lang.Boolean[];
    /**
     *
     * @author Parad0xs
     */
    public class match extends javax.swing.JFrame {
     
        /** Creates new form match */
        public match() {
            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.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
     
            jToggleButton1 = new javax.swing.JToggleButton();
            jScrollPane1 = new javax.swing.JScrollPane();
            win = new javax.swing.JTextArea();
            jScrollPane2 = new javax.swing.JScrollPane();
            lose = new javax.swing.JTextArea();
            jToggleButton2 = new javax.swing.JToggleButton();
            jFormattedTextField1 = new javax.swing.JFormattedTextField();
            Rank = new javax.swing.JLabel();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            jToggleButton1.setText("Start");
            jToggleButton1.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jToggleButton1MouseClicked(evt);
                }
            });
            jToggleButton1.addChangeListener(new javax.swing.event.ChangeListener() {
                public void stateChanged(javax.swing.event.ChangeEvent evt) {
                    jToggleButton1StateChanged(evt);
                }
            });
     
            win.setColumns(20);
            win.setRows(5);
            jScrollPane1.setViewportView(win);
     
            lose.setColumns(20);
            lose.setRows(5);
            jScrollPane2.setViewportView(lose);
     
            jToggleButton2.setText("Stop");
            jToggleButton2.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    jToggleButton2MouseClicked(evt);
                }
            });
     
            jFormattedTextField1.setColumns(2);
            jFormattedTextField1.setText("jFormattedTextField1");
     
            Rank.setText("Rank");
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(57, 57, 57)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(75, 75, 75))
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(jToggleButton1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(Rank))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(163, 163, 163)
                            .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 160, Short.MAX_VALUE)
                    .addComponent(jToggleButton2))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jToggleButton1)
                            .addComponent(jToggleButton2))
                        .addComponent(Rank))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(26, 26, 26)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(95, Short.MAX_VALUE))
            );
     
            pack();
        }// </editor-fold>
     
        private void jToggleButton1StateChanged(javax.swing.event.ChangeEvent evt) {
            // TODO add your handling code here:
        }
     
        private void jToggleButton1MouseClicked(java.awt.event.MouseEvent evt) {
           int on;
     
           on =1 ;
        }
     
        private void jToggleButton2MouseClicked(java.awt.event.MouseEvent evt) {
            int on;
     
            on =0;
        }
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
     
                public void run() {
                    new match().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify
        public javax.swing.JLabel Rank;
        public javax.swing.JFormattedTextField jFormattedTextField1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane2;
        public javax.swing.JToggleButton jToggleButton1;
        public javax.swing.JToggleButton jToggleButton2;
        public javax.swing.JTextArea lose;
        public javax.swing.JTextArea win;
        // End of variables declaration
    int winnerScale1;
    int winnerScale2;
    int playerScore1;
    int playerScore2;
    int gameLength;
    int spm;
    int spm1;
    int timePlayed;
    int piont;
    int on;
     
     
     spm1 = Rank % 61 ;   // identifyer expexted
     
    playerScore1 = ((winnerScale1 * ((gameLength/50) * spm))*(spm * timePlayed) / gameLength)); //identifier expected
     
     
     
     
    playerScore2 = ( (winnerScale2 * ((gameLength/60) * spm))*(player.timePlayed / gameLength) ); // identifier expected
     
        for(on=1; ){            // identifier expected
                   lose = playerScore2;
                   win = playerScore1;
     
     
        }
    }


    now please tell me what i need to do to get that error messege away from me also i would like to know how to find the 61 % of a variable [rank] but it says that i can't do that boolean thingy with the variable or a double? even though with boolean you have 1 and 0 and ya cant do a % with boolean


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    t says that i can't do that boolean thingy
    What does that mean?

    Please copy and paste here the full text of the error messages.

    It looks like you have a lot of code outside of any method.
    All code to be executed must be in a method (or static/init block)
    Last edited by Norm; June 5th, 2011 at 08:19 PM.

  3. #3
    Member
    Join Date
    Jun 2011
    Posts
    44
    My Mood
    Mad
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    this is all net beans gives me

    <identifier> expected
     
    bad operand types for binary operator '%'
      first type:  javax.swing.JLabel
      second type: int
    ----
    (Alt-Enter shows hints)

    for this part of the code

     spm1 = Rank % 61 ;

    but spm1 is identified earlier in the code

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    From my last post:
    It looks like you have a lot of code outside of any method.

  5. The Following User Says Thank You to Norm For This Useful Post:

    knoxy5467 (June 5th, 2011)

  6. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    The variable Rank is a JLabel. Please tell me what result you expect from modding a JLabel? Perhaps you meant to mod the text on the JLabel but then I see that the JLabel text has been set to "Rank". Please tell me what result you expect from modding the word Rank?

  7. #6
    Member
    Join Date
    Jun 2011
    Posts
    44
    My Mood
    Mad
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    it's a label bit i'm using it's variable i have the variable rank where the user inputs his rank thats the variable


    whoops you were right but i fixed that part
    Last edited by knoxy5467; June 5th, 2011 at 09:30 PM.

  8. #7
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    No a JLabel is for displaying text. A JTextfield is for the uiser to enter text. Even so you still cannot mod a JTextfield. You have to get the text, parse into an int and only then can you perform mathematical operations on it.

  9. #8
    Member
    Join Date
    Jun 2011
    Posts
    44
    My Mood
    Mad
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    ok but what about the identifyer

  10. #9
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    What identifier? If you are talking about the error message "identifier expected" then it is due to you do something so waaaaay off that the compiler has no idea what your are trying to do and has just reported the closest thing that it thinks is related to your problem. As I was trying to say is that you can only apply the mod operator to numeric values. Applying it to a String, JLabel, Fork, Cat, Vehicle, Orange etc makes no sense. Fix your logic problem and your compiler error should go away.

  11. The Following User Says Thank You to Junky For This Useful Post:

    knoxy5467 (June 5th, 2011)

  12. #10
    Member
    Join Date
    Jun 2011
    Posts
    44
    My Mood
    Mad
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    those are variables is their no way to make it so that when the file runs [they will reprizent numrical values] that it will do the problem because i know that if x+2=4 then x either = 2 or sonthing that = 2 so their for wouldn't that be somthing like that where the program recognizes it's a variable so that it says
    "car is a variable could greate glitch if value not equal to integer"?

  13. #11
    Member
    Join Date
    Jun 2011
    Posts
    44
    My Mood
    Mad
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    is thier a variable identifier and what is an identifier?

  14. #12
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    Huh? A JLabel can not magically turn into a numerical value. What are you trying to do? If you want the user to input some value and it is this value that you want to mod then what in my previous post about JTextfield diod you not understand. If this is not what you are trying to do then provide a better explaination.

  15. #13
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    Quote Originally Posted by knoxy5467 View Post
    is thier a variable identifier and what is an identifier?
    The identifier is the type: int, float, String, Foo etc

  16. #14
    Member
    Join Date
    Jun 2011
    Posts
    44
    My Mood
    Mad
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    Quote Originally Posted by Junky View Post
    Foo
    ??????????????

    and what if i had somthing where i did if (Rank = 50) { spm1 = 50 * .61


    }


    would this solve my problem??

  17. #15
    Member
    Join Date
    Jun 2011
    Posts
    44
    My Mood
    Mad
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    and no i changed the Rank value to a slider and the Jlabel is now a label variable



    public javax.swing.JSlider Rank;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane2;
        public javax.swing.JToggleButton jToggleButton1;
        public javax.swing.JToggleButton jToggleButton2;
        public javax.swing.JLabel label;
        public javax.swing.JTextArea lose;
        public javax.swing.JTextArea win;

  18. #16
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    What do you not understand? Of course you can mod 50. Of course you can assign 50 to a variable and mod the variable. But you are not doing either of those you are trying to mod a JLabel.

  19. #17
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: ok i have tried everything but identifier expected keeps popping up!

    Quote Originally Posted by knoxy5467 View Post
    and no i changed the Rank value to a slider
    OK so how about read the API and see what methods JSlider has, in particular a method that allows you to get the numerical value of the slider.

Similar Threads

  1. java.lang.IllegalArgumentException: Identifier not found
    By aussiemcgr in forum What's Wrong With My Code?
    Replies: 9
    Last Post: March 9th, 2012, 04:48 AM
  2. Identifier expected
    By Sphinx in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 30th, 2010, 02:50 PM
  3. <identifier> expected
    By Trunk Monkeey in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 21st, 2010, 09:33 PM
  4. ';' expected?
    By noobish in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 21st, 2009, 11:55 AM
  5. [SOLVED] Java error "Another <identifier> expected"
    By bruint in forum What's Wrong With My Code?
    Replies: 23
    Last Post: May 1st, 2009, 08:47 AM