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: Problem with Action Event

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Problem with Action Event

    Hey guys,
    i am quite new to Java and i just started learning this ActionEvent and im getting semicolons errors.
    mind to help me?

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
     
    	public class LongDistanceCall extends JFrame implements ActionListener
    	{
    		JLabel lbl1,lbl2,lbl3,lbl4;
    		JTextField tf1,tf2,tf3;
    		JRadioButton rb1,rb2,rb3;
    		JPanel p1,p2,p3,p4,p5;
    		rb1.add ActionListener(this);
    		rb2.add ActionListener(this);
    		rb3.add ActionListener(this);
     
        public static void main (String [] arg)
        {
        	LongDistanceCall fr = new LongDistanceCall();
        	fr.setSize(300,250);//pack();
        	fr.setVisible(true);
        	fr.setTitle("Long Distance Call");
        	fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
     
        public LongDistanceCall()
        {
        	lbl1 = new JLabel("Enter hours of the call:");
        	lbl2 = new JLabel("Enter Minutes of the call:");
        	lbl3 = new JLabel("Rate Category:");
        	lbl4 = new JLabel("Charges for the call:RM");
     
        	tf1 = new JTextField(5);
        	tf2 = new JTextField(5);
        	tf3 = new JTextField(5);
     
        	rb1 = new JRadioButton("Daytime  (6am - 5.59am)");
        	rb2 = new JRadioButton("Evening  (6pm - 11.59pm)");
        	rb3 = new JRadioButton("off-Peak (12am - 5.59am)");
     
        	p1 = new JPanel();
        	p1.setLayout(new GridLayout(1,2));
        	p1.add(lbl1);
        	p1.add(tf1);
     
        	p2 = new JPanel();
        	p2.setLayout(new GridLayout(1,2));
        	p2.add(lbl2);
        	p2.add(tf2);
     
        	p3 = new JPanel();
        	p3.setLayout(new GridLayout(1,2));
        	p3.add(lbl3);
     
        	p4 = new JPanel();
        	p4.setLayout(new GridLayout(3,2));
        	p4.add(rb1);
        	p4.add(rb2);
        	p4.add(rb3);
     
        	p5 = new JPanel();
        	p5.add(lbl4);
        	p5.add(tf3);
     
    		setLayout(new GridLayout(5,1));
    		add(p1);
    		add(p2);
    		add(p3);
    		add(p4);
    		add(p5);
     
     
     
     
        }
     
    	public void ActionPerformed(Action Event.e))
    	{
    		double hours = Double parseDouble(tf1.getText());
    		double minutes = Double parseDouble(tf2.getText());
    		double rate = 0;
    		if(e.getSource() == rb1)
    		{
    			rate = 0.07;
    		}
    		if(e.getSource() == rb2)
    		{
    			rate = 0.12;
    		}
    		if(e.getSource() == rb3)
    		{
    			rate = 0.05;
    		}
     
    		double duration = (hours*60)+(minutes);
    		double total = duration * rate;
    		tf3.setText(String ValueOf(total));
     
    	}
     
     
    }

    Hope to get help
    thnx!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,717
    Thanks
    45
    Thanked 1,973 Times in 1,947 Posts

    Default Re: Problem with Action Event

    Please post the full text of the error messages that show where the problem is.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Action Event

    Quote Originally Posted by Norm View Post
    Please post the full text of the error messages that show where the problem is.
    illegal start of type
    illegal start of type
    illegal start of type
    ')' expected
    <identifier> expected
    illegal start of type
    <identifier> expected
    ';' expected
    <identifier> expected
    ';' expected
    invalid method declaration; return type required
    <identifier> expected
    ';' expected
    illegal start of type
    <identifier> expected
    ';' expected
    <identifier> expected
    ';' expected
    invalid method declaration; return type required
    <identifier> expected
    ';' expected
    illegal start of type
    <identifier> expected
    ';' expected
    <identifier> expected
    illegal start of type
    <identifier> expected
    ';' expected
    illegal start of type
    ';' expected
    illegal start of type
    <identifier> expected
    ';' expected
    illegal start of type
    ';' expected
    illegal start of type
    <identifier> expected
    ';' expected
    illegal start of type
    ';' expected
    <identifier> expected
    ')' expected
    <identifier> expected
    illegal start of type
    <identifier> expected
    ';' expected

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,717
    Thanks
    45
    Thanked 1,973 Times in 1,947 Posts

    Default Re: Problem with Action Event

    Please post the full text of the error messages that show where the problem is.
    The error messages you posted do NOT show what source line the error is on.
    Here is a sample of error message that shows where and what the error is:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^

    These messages are from the javac command.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Action Event

    Sorry Norm,
    Here it is.

    --------------------Configuration: <Default>--------------------
    C:\Users\Justin\Desktop\LongDistanceCall.java:11: illegal start of type
            rb1.add ActionListener(this);
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:12: illegal start of type
            rb2.add ActionListener(this);
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:13: illegal start of type
            rb3.add ActionListener(this);
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: ')' expected
        public void ActionPerformed(Action Event.e))
     
                                                ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: <identifier> expected
        public void ActionPerformed(Action Event.e))
                                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: illegal start of type
        public void ActionPerformed(Action Event.e))
                                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: <identifier> expected
        public void ActionPerformed(Action Event.e))
                                                    ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:76: ';' expected
        {
         ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: <identifier> expected
            double hours = Double parseDouble(tf1.getText());
                        ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: ';' expected
            double hours = Double parseDouble(tf1.getText());
                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: invalid method declaration; return type required
            double hours = Double parseDouble(tf1.getText());
                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: <identifier> expected
            double hours = Double parseDouble(tf1.getText());
                                                         ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: ';' expected
            double hours = Double parseDouble(tf1.getText());
                                                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: illegal start of type
            double hours = Double parseDouble(tf1.getText());
                                                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: <identifier> expected
            double hours = Double parseDouble(tf1.getText());
                                                            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: ';' expected
            double hours = Double parseDouble(tf1.getText());
                                                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: <identifier> expected
            double minutes = Double parseDouble(tf2.getText());
                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: ';' expected
            double minutes = Double parseDouble(tf2.getText());
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: invalid method declaration; return type required
            double minutes = Double parseDouble(tf2.getText());
                                    ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: <identifier> expected
            double minutes = Double parseDouble(tf2.getText());
                                                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: ';' expected
            double minutes = Double parseDouble(tf2.getText());
                                                            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: illegal start of type
            double minutes = Double parseDouble(tf2.getText());
                                                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: <identifier> expected
            double minutes = Double parseDouble(tf2.getText());
                                                              ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: ';' expected
            double minutes = Double parseDouble(tf2.getText());
                                                               ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:79: <identifier> expected
            double rate = 0;
                       ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: illegal start of type
            if(e.getSource() == rb1)
            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: <identifier> expected
            if(e.getSource() == rb1)
                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: ';' expected
            if(e.getSource() == rb1)
                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: illegal start of type
            if(e.getSource() == rb1)
                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: ';' expected
            if(e.getSource() == rb1)
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: illegal start of type
            if(e.getSource() == rb2)
            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: <identifier> expected
            if(e.getSource() == rb2)
                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: ';' expected
            if(e.getSource() == rb2)
                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: illegal start of type
            if(e.getSource() == rb2)
                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: ';' expected
            if(e.getSource() == rb2)
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: illegal start of type
            if(e.getSource() == rb3)
            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: <identifier> expected
            if(e.getSource() == rb3)
                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: ';' expected
            if(e.getSource() == rb3)
                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: illegal start of type
            if(e.getSource() == rb3)
                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: ';' expected
            if(e.getSource() == rb3)
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: <identifier> expected
            tf3.setText(String ValueOf(total));
                       ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: ')' expected
            tf3.setText(String ValueOf(total));
                                      ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: <identifier> expected
            tf3.setText(String ValueOf(total));
                                            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: illegal start of type
            tf3.setText(String ValueOf(total));
                                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: <identifier> expected
            tf3.setText(String ValueOf(total));
                                              ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: ';' expected
            tf3.setText(String ValueOf(total));
                                               ^
    46 errors
     
    Process completed.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,717
    Thanks
    45
    Thanked 1,973 Times in 1,947 Posts

    Default Re: Problem with Action Event

    Is there a space between add and ActionListener? Names can not have spaces in them.
    Fix those errors and try again. Sometimes when the compiler gets lost because of this kind of error it flags too many other statements as errors.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Action Event

    Hi Norm, thnx for the replies.
    i tried removing the space but it still have the same Errors.
    Could it be something else?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,717
    Thanks
    45
    Thanked 1,973 Times in 1,947 Posts

    Default Re: Problem with Action Event

    still have the same Errors.
    Please post the full text of the error messages. Fixing the spaces problem should have changed the text of the messages. There must be new errors now.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Action Event

    --------------------Configuration: <Default>--------------------
    C:\Users\Justin\Desktop\LongDistanceCall.java:11: <identifier> expected
            rb1.addActionListener(this);
                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:11: illegal start of type
            rb1.addActionListener(this);
                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:12: <identifier> expected
            rb2.addActionListener(this);
                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:12: illegal start of type
            rb2.addActionListener(this);
                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:13: <identifier> expected
            rb3.addActionListener(this);
                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:13: illegal start of type
            rb3.addActionListener(this);
                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: ')' expected
        public void ActionPerformed(Action Event.e))
                                                ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: <identifier> expected
        public void ActionPerformed(Action Event.e))
                                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: illegal start of type
        public void ActionPerformed(Action Event.e))
                                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: <identifier> expected
        public void ActionPerformed(Action Event.e))
                                                    ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:76: ';' expected
        {
         ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: <identifier> expected
            double hours = Double parseDouble(tf1.getText());
                        ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: ';' expected
            double hours = Double parseDouble(tf1.getText());
                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: invalid method declaration; return type required
            double hours = Double parseDouble(tf1.getText());
                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: <identifier> expected
            double hours = Double parseDouble(tf1.getText());
                                                         ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: ';' expected
            double hours = Double parseDouble(tf1.getText());
                                                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: illegal start of type
            double hours = Double parseDouble(tf1.getText());
                                                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: <identifier> expected
            double hours = Double parseDouble(tf1.getText());
                                                            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: ';' expected
            double hours = Double parseDouble(tf1.getText());
                                                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: <identifier> expected
            double minutes = Double parseDouble(tf2.getText());
                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: ';' expected
            double minutes = Double parseDouble(tf2.getText());
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: invalid method declaration; return type required
            double minutes = Double parseDouble(tf2.getText());
                                    ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: <identifier> expected
            double minutes = Double parseDouble(tf2.getText());
                                                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: ';' expected
            double minutes = Double parseDouble(tf2.getText());
                                                            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: illegal start of type
            double minutes = Double parseDouble(tf2.getText());
                                                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: <identifier> expected
            double minutes = Double parseDouble(tf2.getText());
                                                              ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: ';' expected
            double minutes = Double parseDouble(tf2.getText());
                                                               ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:79: <identifier> expected
            double rate = 0;
                       ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: illegal start of type
            if(e.getSource() == rb1)
            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: <identifier> expected
            if(e.getSource() == rb1)
                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: ';' expected
            if(e.getSource() == rb1)
                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: illegal start of type
            if(e.getSource() == rb1)
                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:80: ';' expected
            if(e.getSource() == rb1)
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: illegal start of type
            if(e.getSource() == rb2)
            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: <identifier> expected
            if(e.getSource() == rb2)
                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: ';' expected
            if(e.getSource() == rb2)
                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: illegal start of type
            if(e.getSource() == rb2)
                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:84: ';' expected
            if(e.getSource() == rb2)
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: illegal start of type
            if(e.getSource() == rb3)
            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: <identifier> expected
            if(e.getSource() == rb3)
                          ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: ';' expected
            if(e.getSource() == rb3)
                           ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: illegal start of type
            if(e.getSource() == rb3)
                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:88: ';' expected
            if(e.getSource() == rb3)
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: <identifier> expected
            tf3.setText(String ValueOf(total));
                       ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: ')' expected
            tf3.setText(String ValueOf(total));
                                      ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: <identifier> expected
            tf3.setText(String ValueOf(total));
                                            ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: illegal start of type
            tf3.setText(String ValueOf(total));
                                             ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: <identifier> expected
            tf3.setText(String ValueOf(total));
                                              ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: ';' expected
            tf3.setText(String ValueOf(total));
                                               ^
    49 errors
     
    Process completed.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,717
    Thanks
    45
    Thanked 1,973 Times in 1,947 Posts

    Default Re: Problem with Action Event

    Are those calls to the addActionListener() method inside of a method? They should be in a method, not just inside the class definition.

    public void ActionPerformed(Action Event.e))
    I thought you removed the all the spaces inside of names. The above statement has a name with a space in it.

    What is the . before the e for?
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Action Event

    My mistake Norm,

    there are still errors, but not as much as the previous one.

    --------------------Configuration: <Default>--------------------
    C:\Users\Justin\Desktop\LongDistanceCall.java:11: <identifier> expected
            rb1.addActionListener(this);
                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:11: illegal start of type
            rb1.addActionListener(this);
                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:12: <identifier> expected
            rb2.addActionListener(this);
                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:12: illegal start of type
            rb2.addActionListener(this);
                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:13: <identifier> expected
            rb3.addActionListener(this);
                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:13: illegal start of type
            rb3.addActionListener(this);
                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: <identifier> expected
        public void ActionPerformed(ActionEvent.e))
                                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:75: ';' expected
        public void ActionPerformed(ActionEvent.e))
                                                  ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:77: ';' expected
            double hours = Double parseDouble(tf1.getText());
                                 ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:78: ';' expected
            double minutes = Double parseDouble(tf2.getText());
                                   ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: ')' expected
            tf3.setText(String ValueOf(total));
                              ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: not a statement
            tf3.setText(String ValueOf(total));
                                      ^
    C:\Users\Justin\Desktop\LongDistanceCall.java:95: ';' expected
            tf3.setText(String ValueOf(total));
                                             ^
    13 errors
     
    Process completed.

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,717
    Thanks
    45
    Thanked 1,973 Times in 1,947 Posts

    Default Re: Problem with Action Event

    Where are the statements causing the first errors with the calls to addActionListener()?
    Are they inside a method?
    public void ActionPerformed(ActionEvent.e))
    Why is there a . before the e? When defining an argument to a method give the name of the class and the name of the variable which are separated by a space.

    Double parseDouble(tf2.getText());
    What is that expression supposed to be doing?
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Action Event

    Quote Originally Posted by Norm View Post
    What is that expression supposed to be doing?
    isnt that expression converts from string to double?
    I got this from my lecturer... and i am confused the way she teaches.

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,717
    Thanks
    45
    Thanked 1,973 Times in 1,947 Posts

    Default Re: Problem with Action Event

    When you call a method, you must specify what class the method is in followed by a . followed by the method name:
    theClass.theMethod(...);
    For static methods you use the classname for theClass.
    For non static methods you use a reference to a class object.
    Last edited by Norm; August 29th, 2012 at 09:47 AM.
    If you don't understand my answer, don't ignore it, ask a question.

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

    jayzee98 (August 29th, 2012)

  16. #15
    Junior Member
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Action Event

    Norm, im sorry could you explain it in a more basic war
    i cant really understand actually, Im sorry

  17. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,717
    Thanks
    45
    Thanked 1,973 Times in 1,947 Posts

    Default Re: Problem with Action Event

    What text book or tutorial are you using? These are very basic concepts that should have been covered in a student's textbook.

    Here are some tutorials. Also ask google about calling methods in java.
    Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    Returning a Value from a Method (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    If you don't understand my answer, don't ignore it, ask a question.

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

    jayzee98 (August 29th, 2012)

  19. #17
    Junior Member
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Action Event

    Thnx Norm for helping me!
    I will go re-read my tutorials and try to find out more of the problems.

    and thanks again for helping me!

Similar Threads

  1. add action listener problem
    By mdhmdh100 in forum AWT / Java Swing
    Replies: 5
    Last Post: February 5th, 2012, 01:53 AM
  2. [SOLVED] difference between action event from 2 buttons with same name?
    By nggdowt in forum AWT / Java Swing
    Replies: 5
    Last Post: November 7th, 2011, 09:51 AM
  3. Replies: 9
    Last Post: June 29th, 2011, 12:27 PM
  4. jbutton and action event
    By mt888 in forum AWT / Java Swing
    Replies: 3
    Last Post: March 26th, 2010, 06:24 AM
  5. Problem with Action Listener
    By JonoScho in forum AWT / Java Swing
    Replies: 4
    Last Post: March 19th, 2010, 01:03 AM

Tags for this Thread