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 2 of 2

Thread: I don't understand what's wrong in my programme

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I don't understand what's wrong in my programme

    hi I have problem in result of my program : the event not generated and the result not shown,
    Please help me to solve this , I am beginner in Java I use Netbeans.
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package score;
     
    /**
     *
     * @author hhbest
     */
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.border.Border;
     
     
    //le class commence ici
     
    /**
     *
     * @author hhbest
     */
    public class Score extends JFrame implements ActionListener,ItemListener {
     
        ButtonGroup option = new ButtonGroup();
        ButtonGroup option1 = new ButtonGroup();
        ButtonGroup option2 = new ButtonGroup();
        ButtonGroup option3 = new ButtonGroup();
        int rep;
        int clcScore;
    //    ROW 1
            JPanel row1 = new JPanel();
            JCheckBox rep1 = new JCheckBox("Oui", false);
            JCheckBox rep2 = new JCheckBox("Nom", false);
            JLabel testlabel= new JLabel("Je prends facilement et regulierement les avis des autres sur mon travail......"
                    , JLabel.LEFT);
     
    //        ROW 2
            JPanel row2 = new JPanel();
            JCheckBox rep3 = new JCheckBox("Oui", false);
            JCheckBox rep4 = new JCheckBox("Nom", false);
            JLabel testlabel2= new JLabel("Je prends facilement et regulierement les avis des autres sur mon travail......"
                    , JLabel.LEFT);
    //        ROW 3
        JPanel row3 = new JPanel();
            JCheckBox rep5 = new JCheckBox("Oui", false);
            JCheckBox rep6 = new JCheckBox("Nom", false);
            JLabel testlabel3= new JLabel("Je prends facilement et regulierement les avis des autres sur mon travail......"
                    , JLabel.LEFT);
    //        ROW 4
            BorderLayout crisisLayout = new BorderLayout();
            JPanel row4 = new JPanel();
     
            JLabel testlabel4= new JLabel("le resulta est: 0 " , JLabel.LEFT);
     
     
        public Score () {
            super("Mon style de communication");
            setLookAndFeel();
            setSize(650, 300);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            GridLayout layout = new GridLayout(5, 1, 10, 10);
            setLayout(layout);
            FlowLayout layout1 = new FlowLayout(FlowLayout.LEFT,10, 10);
            FlowLayout layout2 = new FlowLayout(FlowLayout.LEFT,10, 10);
            FlowLayout layout3 = new FlowLayout(FlowLayout.LEFT,10, 10);
            FlowLayout layout4 = new FlowLayout(FlowLayout.LEFT,10, 10);
    //        GRAPHIC ROW 1
            row1.setLayout(layout1);
            row1.add(testlabel);
            option.add(rep1);
            option.add(rep2);
            row1.setLayout(layout1);
            row1.add(rep1);
            row1.add(rep2);        
            add(row1);
    //        GRAPHIC ROW 2
            row2.setLayout(layout2);
            row2.add(testlabel2);
            option1.add(rep3);
            option1.add(rep4);
            row2.setLayout(layout2);
            row2.add(rep3);
            row2.add(rep4);  
            add(row2);
    //        GRAPHIC ROW 3
            row3.setLayout(layout3);
            row3.add(testlabel3);
            option2.add(rep5);
            option2.add(rep6);
            row3.setLayout(layout3);
            row3.add(rep5);
            row3.add(rep6);  
            add(row3);
    //        Graphic ROW 4
            row4.setLayout(layout4);
            JButton calaculBtn = new JButton("Calculer");
            row4.add(calaculBtn, BorderLayout.NORTH);
            row4.add(testlabel4);
            add(testlabel4);
            add(calaculBtn);
            FlowLayout flo = new FlowLayout();
            setLayout(flo);
            add(calaculBtn);
    //        Events
            rep1.addItemListener(this);
            rep3.addItemListener(this);
            rep5.addItemListener(this);
            calaculBtn.addActionListener(new ActionListener(){
                 public void actionPerformed(ActionEvent event) {
        String Calculer = event.getActionCommand();
     
      while (Calculer == event.getSource() ) {
           clcScore = (rep++)/2;
           testlabel4.setText(Integer.toString(clcScore));
       }
     
     
    }
            });
     
            setVisible(true); 
     
     
        }
        /**
         *
         * @param e
         */
        public void itemStatechanged(ItemEvent event){
            if(event.getStateChange() == ItemEvent.SELECTED){
                rep=1;
            } else if(event.getStateChange() == ItemEvent.DESELECTED){
                rep = 0;
            }
        }
     
     
     
     
        /**
         *
         * @param event
         */
     
     
        private void setLookAndFeel() {
    try {
    UIManager.setLookAndFeel(
     "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"
    );
    } catch (Exception exc) {
    //    ignior errors
    }
     
     
    }/**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
            Score Sc = new Score();
     
     
        }
     
        @Override
        public void itemStateChanged(ItemEvent ie) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
     
        @Override
        public void actionPerformed(ActionEvent ae) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
     
     
     
     
     
    }
    thanks .


  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: I don't understand what's wrong in my programme

    I have problem in result of my program : the event not generated and the result not shown,
    Can you explain? Are there error messages? Please copy the full text and paste it here.
    Is the results of the program's execution unexpected? Please give some evidence showing what is happening and explain what the problem is.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Don't understand why it loops through multiple times...
    By Discoveringmypath in forum Loops & Control Statements
    Replies: 4
    Last Post: January 26th, 2013, 09:00 PM
  2. [SOLVED] Gotten easy code by proffessor that I don't understand, do you?
    By matitorn in forum Java Theory & Questions
    Replies: 7
    Last Post: October 9th, 2012, 01:30 PM
  3. Don't understand void methods, need help!
    By alex067 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 9th, 2012, 07:02 AM
  4. Simply don't understand minimax...
    By Herah in forum Algorithms & Recursion
    Replies: 3
    Last Post: October 13th, 2011, 12:45 PM
  5. I don't understand what I'm supposed to do
    By dmcettrick in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 11th, 2011, 09:34 AM