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.

Page 1 of 2 12 LastLast
Results 1 to 25 of 26

Thread: action listener not working help

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation action listener not working help

    Hi thanks for the post.The first panel is printed with its buttons but nothing happens on clicking them.I may not have been edited the posted properly cause I am new here and this my first post.the program is written in bluej environment.




    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class TempConverter extends JFrame implements ActionListener
    {
       int inScale=0,outScale=0;//stores scale of input and output temperature
       String p="";//To store action command
       ButtonGroup inputGroup,outputGroup;
       JRadioButton b1_panel1,b2_panel1,b3_panel1;//radio buttons for selecting input temperature
       JRadioButton  b1_panel2,b2_panel2,b3_panel2;//radio buttons for selecting output temperatures
       JButton b1_panel3,b2_panel3;//buttons for third panel
       JTextField t1,t2;//for inputing and outputing statements
       JPanel panel1,panel2,panel3;//panels for output and selcting scales
       JLabel l1,l2;//to inform about input and output scales
       public void frame()//to initialise frame
       {
          this.setSize(500,500);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          this.setPreferredSize(this.getPreferredSize());
          this.setVisible(true);
       }
       public void panel1()//to initialise first panel
       {
          b1_panel1=new JRadioButton("Kelvin");
          b2_panel1=new JRadioButton("Fahrenheit");
          b3_panel1=new JRadioButton("Celsius");
          inputGroup=new ButtonGroup();
          inputGroup.add(b1_panel1);
          inputGroup.add(b2_panel1);
          inputGroup.add(b3_panel1);
          l1=new JLabel("INPUT SCALE");
          panel1=new JPanel();
          panel1.setLayout(new BoxLayout(panel1,BoxLayout.LINE_AXIS));
          panel1.add(l1);
          panel1.add(b1_panel1);
          panel1.add(b2_panel1);
          panel1.add(b3_panel1);
          panel1.setPreferredSize(panel1.getPreferredSize());
          panel1.setVisible(true);
       }
       public void panel2()//to initialse second panel   
       {
          b1_panel2=new JRadioButton("Kelvin");
          b2_panel2=new JRadioButton("Fahrenheit");
          b3_panel2=new JRadioButton("Celsius");
          outputGroup=new ButtonGroup();
          outputGroup.add(b1_panel2);
          outputGroup.add(b2_panel2);
          outputGroup.add(b3_panel2);
          l2=new JLabel("OUTPUT SCALE");
          panel2=new JPanel();
          panel2.setLayout(new BoxLayout(panel2,BoxLayout.PAGE_AXIS));
          panel2.add(l2);
          panel2.add(b1_panel2);
          panel2.add(b2_panel2);
          panel2.add(b3_panel2);
          panel2.setPreferredSize(panel2.getPreferredSize());
          panel2.setVisible(true);
       }
       public void panel3()//to initialise third panel   
       {   
          b1_panel3=new JButton("CONVERT");
          b2_panel3=new JButton("Back");
          panel3=new JPanel();
          panel3.setLayout(new BoxLayout(panel3,BoxLayout.PAGE_AXIS));
          t1=new JTextField("Enter input temperature");
          t2=new JTextField();
          panel3.add(t1);
          panel3.add(b1_panel3);
          panel3.add(t2);
          panel3.add(b2_panel3);
          panel3.setPreferredSize(panel3.getPreferredSize());
          panel3.setVisible(true);
       }
       public void start()//to add first panel to frame and set action commands
       {
          b1_panel1.addActionListener(this);
          b1_panel1.setActionCommand("11");//first digit stores panel bieng used and second stores which button is pressed
          b2_panel1.addActionListener(this);
          b2_panel1.setActionCommand("12");
          b3_panel1.addActionListener(this);
          b3_panel1.setActionCommand("13");
          b1_panel2.addActionListener(this);
          b1_panel2.setActionCommand("21");
          b2_panel2.addActionListener(this);
          b2_panel2.setActionCommand("22");
          b3_panel2.addActionListener(this);
          b3_panel2.setActionCommand("23");
          b1_panel3.addActionListener(this);
          b1_panel3.setActionCommand("31");
          b2_panel3.addActionListener(this);
          b2_panel3.setActionCommand("32");
          this.add(panel1);
        }
       public void actionPerformed(ActionEvent e)
       {
           p=e.getActionCommand();
           switch(p.charAt(0))
           {    
               case '1'://first panel is used
               this.removeAll();
               this.add(panel2);
               inScale=Integer.valueOf(p.charAt(1));//setting input scale
               break;
               case '2'://second panel is used
               this.removeAll();
               this.add(panel3);
               outScale=Integer.valueOf(p.charAt(1));//setting output scale
               break;
               case '3'://last panel is used
               switch(p.charAt(1))
               {
                    case '1'://used pressed back button
                    this.removeAll();
                    this.add(panel1);
                    break;
                    case '2'://user pressed convert button
                    Double i=Double.parseDouble(t1.getText());
                    Double r=calculate(i);//converting temperture
                    t2.setText(Double.toString(r));break;
               }   
           }
       }
       public Double calculate(Double i)//to calculate output temperature
       {
               Double r=0.0;
               switch(this.inScale)
               {
                    case 1://input scale=kelvin
                    switch(this.outScale)
                    {
                        case 1://output scale=kelvin
                        r=i;break;
                        case 2://output scale=farenhiet
                        r=9/5*(i-273.15)+32;break;
                        case 3://output scale=celcius
                        r=i-273.15;break;
                    }
                    break;
                    case 2://input scale=farenhiet
                    switch(this.outScale)
                    {
                        case 1://output scale=kelvin
                        r=(5/9*(i-32)+273.15);;break;
                        case 2://output scale=farenhiet
                        r=i;break;
                        case 3://output scale=celcieus
                        r=5/9*(i-32);break;
                    }
                    break;
                    case 3://input scale=celcius
                    switch(this.outScale)
                    {
                        case 1://output scale=kelvin
                        r=i+273.15;break;
                        case 2://output scale=farenhiet
                        r=(9/5*i)+32;break;
                        case 3://output scale=celcieus
                        r=i;break;
                    }
                    break;
               }
               return(r);   
       }
    }
    class test
    {
     public static void main(String args[])throws IOException
     {
    TempConverter q=new TempConverter();
       q.setTitle("Temperature Converter");
       q.panel1();
       q.panel2();
       q.panel3();
       q.start();
     }
    }


  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: action listener not working help

    Can you explain what "not working" means?
    If there are errors, copy the full text and paste it here.
    If the output is wrong, copy and paste the output and explain what is wrong.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.


    BTW the poorly named variables make this code very hard to read and understand.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: action listener not working help

    Hi i have edited the post as required.as for the variables this is probably my first proper java guide program hence the poor variables.thanks for replies

  4. #4
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: action listener not working help

    I suggest you to read API documentation before using it... In actionPerformed(), you could just use e.getActionCommand() to check a button (of course, first of all you set the action commands for all the buttons as button.setActionCommand()), and not parse the button's text's first letter. And yes, this code is too difficult to read. Can you do something with it, like creating SSCCE that describes problem?

  5. #5
    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: action listener not working help

    Can you explain what "not working" means?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: action listener not working help

    hi i have edited the code a little and hope it is easier to read i am now getting a null pointer exception at 1)q.start() and 2)f1.add(panel1)

  7. #7
    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: action listener not working help

    now getting a null pointer exception at 1)q.start() and 2)f1.add(panel1)
    Check if the variables: q and f1 have null values causing the NPE. If they do, backtrack in the code to find out why those variables do not have valid values.

    Please copy the full text of the error messages and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: action listener not working help

    So i managed to get your panel to display and i see what you mean by your button not doing anything. It is getting into the action listener just fine.

    #1 Rename your class with a capital letter in front. Class names should start with capitals and objects should have lower case. Google "java camel case" if you need any pointers
    #2 Problems with your GUI.
    ---f1 is not necessary. The class extends jframe so that is your frame. Update its information using "this.setSize()" and so on.
    ---In start() make sure you add all three panels not just panel1. Remember it will be "this.add()"
    ---Suggestion, make one "init()" function that calls all of your init stuff so you dont have to do it in the main function.
    #3 Your action listener. Definitely find a better way of going about this. Those nested switch statements are crazy!
    ---Why are your case statements going to m1, m2, m3? They just clear the frame and add a panel back in, that is where your code is breaking.

    I suggest you add a few System.out.println("Code got here"); lines so you know that you are getting into certain sections. Then clean up that action listener and if you still need help let us know wha tit is actually supposed to be doing.

    --- Update ---

    I lied, a JFrame can only hold one JPanel. You need to make a main JPanel to hold everything else. So if you change f1 to a JPanel and make sure you add f1 to "this" then you should be good.

    --- Update ---

    Just so you know, I've got your program working and converting. I'm not going to give you the code or you'll learn nothing. I will however work with you to get it working. Feel free to message me or IM me and we can work through this. We'll have you up and running by the end of the evening!

    I would recomend once you have it working go back and modify some stuff to make it a little more professional. For instance, look into radio buttons instead of the buttons for the scales. Your current program has no way of informing you what scale you have selected. Even having a label that states what each scale is would be beneficial. Then you can work on changing the way you are referencing buttons in your action listener. Maybe even make a couple separate action listeners for each panel as they each do independent things.
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  9. #9
    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: action listener not working help

    a JFrame can only hold one JPanel
    Not sure what that means. You'll have to explain what you mean.
    JFrame has a container as its content pane that extends the Container class which can hold many other components. Their positioning on the container is controlled by the layout manager it uses.
    If you don't understand my answer, don't ignore it, ask a question.

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

    Chris.Brown.SPE (March 21st, 2013)

  11. #10
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: action listener not working help

    You're right norm, you can use the content pane. Been forever since i've had to do much of anything with a JFrame. What i was referring to is that if you try to do "this.add()" multiple times you're only going to get the final pane on your JFrame. Easier IMO just to add a main JPanel to the frame then add stuff to that. The content pane is another option but i've never bothered.
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  12. #11
    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: action listener not working help

    if you try to do "this.add()" multiple times you're only going to get the final pane
    That's a function of the layout manager. Change to FlowLayout for example and all the add()s will take.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #12
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: action listener not working help

    Wow, time to think before posting. "this.add()" automatically adds to the content pane, you just have to be sure to set the layout of the frame. Simple doing this.setLayout(new FlowLayout()) should be sufficient.
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  14. #13
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: action listener not working help

    i have added radio buttons,changed the names and added components to the class.but now the program is executing but i am gettong nothing on the screen.also i did not clearly understand what you said in your first update and what you want me to do with the action listener.

  15. #14
    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: action listener not working help

    Please post the current version of the code.
    If you don't understand my answer, don't ignore it, ask a question.

  16. #15
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: action listener not working help

    With having your scales as radio buttons, you should not need any action listener for them. Your only action listener should be handling the convert buttons. Then you can either have two action listeners and a function they both call for the convert or have one action listener and just have to check to see what button was pressed. And like Norm said, cant help with the gui being all FUBAR unless you post the new updates to the code.
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  17. #16
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: action listener not working help

    This is the current version of the code!

  18. #17
    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: action listener not working help

    What happens when you compile and execute the new version?
    If you don't understand my answer, don't ignore it, ask a question.

  19. #18
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: action listener not working help

    Nothing at all happens

  20. #19
    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: action listener not working help

    Please post the current version of the code.

    Try debugging the code by adding lots of println() statements that print messages as each method is executed so you can see where the execution of the code is happening. Start in the main() method and then in each method that needs to be called for the GUI to be displayed.
    If you don't understand my answer, don't ignore it, ask a question.

  21. #20
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: action listener not working help

    This is the latest version of the code

  22. #21
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: action listener not working help

    Your main function is written incorrectly. The brackets go on the String not args.

    --- Update ---

    More problems, you're not going to see anything because you never set your frame visibility to true. Next, you will only see one panel because you arent adding more than just panel1 to your frame.
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  23. #22
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: action listener not working help

    i cant understand what you want me to do can you just post the correct codes .also tell me what i should for my nested switch case

  24. #23
    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: action listener not working help

    Please post the current version of the code.
    If you don't understand my answer, don't ignore it, ask a question.

  25. #24
    Junior Member
    Join Date
    Mar 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: action listener not working help

    This is the latest version of the code

  26. #25
    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: action listener not working help

    Are you saying that you have NOT changed the code since the first post on March 16?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class TempConverter extends JFrame implements ActionListener
    {
       int inScale=0,outScale=0;//stores scale of input and output temperature
       String p="";//To store action command
       ButtonGroup inputGroup,outputGroup;
       JRadioButton b1_panel1,b2_panel1,b3_panel1;//radio buttons for selecting input temperature
       JRadioButton  b1_panel2,b2_panel2,b3_panel2;//radio buttons for selecting output temperatures
       JButton b1_panel3,b2_panel3;//buttons for third panel
       JTextField t1,t2;//for inputing and outputing statements
       JPanel panel1,panel2,panel3;//panels for output and selcting scales
       JLabel l1,l2;//to inform about input and output scales
       public void frame()//to initialise frame
       {
          this.setSize(500,500);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          this.setPreferredSize(this.getPreferredSize());
          this.setVisible(true);
       }
       public void panel1()//to initialise first panel
       {
          b1_panel1=new JRadioButton("Kelvin");
          b2_panel1=new JRadioButton("Fahrenheit");
          b3_panel1=new JRadioButton("Celsius");
          inputGroup=new ButtonGroup();
          inputGroup.add(b1_panel1);
          inputGroup.add(b2_panel1);
          inputGroup.add(b3_panel1);
          l1=new JLabel("INPUT SCALE");
          panel1=new JPanel();
          panel1.setLayout(new BoxLayout(panel1,BoxLayout.LINE_AXIS));
          panel1.add(l1);
          panel1.add(b1_panel1);
          panel1.add(b2_panel1);
          panel1.add(b3_panel1);
          panel1.setPreferredSize(panel1.getPreferredSize());
          panel1.setVisible(true);
       }
       public void panel2()//to initialse second panel   
       {
          b1_panel2=new JRadioButton("Kelvin");
          b2_panel2=new JRadioButton("Fahrenheit");
          b3_panel2=new JRadioButton("Celsius");
          outputGroup=new ButtonGroup();
          outputGroup.add(b1_panel2);
          outputGroup.add(b2_panel2);
          outputGroup.add(b3_panel2);
          l2=new JLabel("OUTPUT SCALE");
          panel2=new JPanel();
          panel2.setLayout(new BoxLayout(panel2,BoxLayout.PAGE_AXIS));
          panel2.add(l2);
          panel2.add(b1_panel2);
          panel2.add(b2_panel2);
          panel2.add(b3_panel2);
          panel2.setPreferredSize(panel2.getPreferredSize());
          panel2.setVisible(true);
       }
       public void panel3()//to initialise third panel   
       {   
          b1_panel3=new JButton("CONVERT");
          b2_panel3=new JButton("Back");
          panel3=new JPanel();
          panel3.setLayout(new BoxLayout(panel3,BoxLayout.PAGE_AXIS));
          t1=new JTextField("Enter input temperature");
          t2=new JTextField();
          panel3.add(t1);
          panel3.add(b1_panel3);
          panel3.add(t2);
          panel3.add(b2_panel3);
          panel3.setPreferredSize(panel3.getPreferredSize());
          panel3.setVisible(true);
       }
       public void start()//to add first panel to frame and set action commands
       {
          b1_panel1.addActionListener(this);
          b1_panel1.setActionCommand("11");//first digit stores panel bieng used and second stores which button is pressed
          b2_panel1.addActionListener(this);
          b2_panel1.setActionCommand("12");
          b3_panel1.addActionListener(this);
          b3_panel1.setActionCommand("13");
          b1_panel2.addActionListener(this);
          b1_panel2.setActionCommand("21");
          b2_panel2.addActionListener(this);
          b2_panel2.setActionCommand("22");
          b3_panel2.addActionListener(this);
          b3_panel2.setActionCommand("23");
          b1_panel3.addActionListener(this);
          b1_panel3.setActionCommand("31");
          b2_panel3.addActionListener(this);
          b2_panel3.setActionCommand("32");
          this.add(panel1);
        }
       public void actionPerformed(ActionEvent e)
       {
           p=e.getActionCommand();
           switch(p.charAt(0))
           {    
               case '1'://first panel is used
               this.removeAll();
               this.add(panel2);
               inScale=Integer.valueOf(p.charAt(1));//setting input scale
               break;
               case '2'://second panel is used
               this.removeAll();
               this.add(panel3);
               outScale=Integer.valueOf(p.charAt(1));//setting output scale
               break;
               case '3'://last panel is used
               switch(p.charAt(1))
               {
                    case '1'://used pressed back button
                    this.removeAll();
                    this.add(panel1);
                    break;
                    case '2'://user pressed convert button
                    Double i=Double.parseDouble(t1.getText());
                    Double r=calculate(i);//converting temperture
                    t2.setText(Double.toString(r));break;
               }   
           }
       }
       public Double calculate(Double i)//to calculate output temperature
       {
               Double r=0.0;
               switch(this.inScale)
               {
                    case 1://input scale=kelvin
                    switch(this.outScale)
                    {
                        case 1://output scale=kelvin
                        r=i;break;
                        case 2://output scale=farenhiet
                        r=9/5*(i-273.15)+32;break;
                        case 3://output scale=celcius
                        r=i-273.15;break;
                    }
                    break;
                    case 2://input scale=farenhiet
                    switch(this.outScale)
                    {
                        case 1://output scale=kelvin
                        r=(5/9*(i-32)+273.15);;break;
                        case 2://output scale=farenhiet
                        r=i;break;
                        case 3://output scale=celcieus
                        r=5/9*(i-32);break;
                    }
                    break;
                    case 3://input scale=celcius
                    switch(this.outScale)
                    {
                        case 1://output scale=kelvin
                        r=i+273.15;break;
                        case 2://output scale=farenhiet
                        r=(9/5*i)+32;break;
                        case 3://output scale=celcieus
                        r=i;break;
                    }
                    break;
               }
               return(r);   
       }
    }
    class test
    {
     public static void main(String args[])throws IOException
     {
    TempConverter q=new TempConverter();
       q.setTitle("Temperature Converter");
       q.panel1();
       q.panel2();
       q.panel3();
       q.start();
     }
    }

    The above code has a compiler error that needs to be fixed.

    You need to read the tutorial on how to build a Swing GUI:
    http://docs.oracle.com/javase/tutori...ing/index.html
    If you don't understand my answer, don't ignore it, ask a question.

Page 1 of 2 12 LastLast

Similar Threads

  1. JMenuItem action Listener
    By WackoMako in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 11th, 2012, 12:59 PM
  2. Action Listener Error
    By dookie1293 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 22nd, 2011, 09:34 PM
  3. Action Listener
    By Suzanne in forum What's Wrong With My Code?
    Replies: 7
    Last Post: May 29th, 2010, 10:50 AM
  4. Action Listener
    By kray66 in forum AWT / Java Swing
    Replies: 2
    Last Post: April 19th, 2010, 03:26 PM
  5. Need Help Action Listener....
    By vhizent23 in forum AWT / Java Swing
    Replies: 2
    Last Post: October 9th, 2009, 01:46 PM