473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Error message

I keep getting and error message (<identifier> expected
myButton.addActionListener;). Can anyone point me in the right direction?





import java.util.*;
import java.swing.*;
import java.awt.*;
import java.event.*;

public class JRS_WK1 extends JFrame implements ActionListener
{//1
JButton myButton;

public static void main(String[]args)
{//2
GUI_JButton_Listener buttonGui = new GUI_JBtutton_Listener();
buttonGui.go();
}//1

//Declare variables
double a, t, i, p;//variables that will be used
JLabel amountLb1, termLb1, interestLb1, paymentLb1;//create labels
JTextField amountTf, termTf, interestTf, paymentsTf;//create text fields
JButton mybutton;// creats a button
JFrame myframe = new JFrame();// makes the frame
JButton myButton = new JButton("Calculate");
myButton.addActionListener;
myFrame.getContentPane().add(myButton);
myFrame.setsize(250,250);
myFrame.setVisible(true);

//Construction of rows in the panel
amountLb1 = new JLabel("Principle");
termLb1 = new JLabel("Term of loan");
interestLb1 = new JLabel("Interest Rate");
paymentLb1 = new JLabel("Monthly Payment");
amountTf = new JTextField();
termTf = new JTextField();
interestTf = new JTextField();
paymentTf = new JTextField();
myButton = new JButton("Calculate");

//Construction of the panel
myFrame = new JFrame("Mortgage Calculato");
myFrame.add(amountLb1);
myFrame.add(amountTf);
myFrame.add(termLb1);
myFrame.add(termTf);
myFrame.add(interestLb1);
myFrame.add(interestTf);
myFrame.add(paymentLb1);
myFrame.add(paymentTf);
myFrame.add(myButton);

}//2
Mar 17 '07 #1
4 1476
hirak1984
316 100+
where is your actionListener method?

if you implement an actionListener you have to make an actionListener method,right?

I keep getting and error message (<identifier> expected
myButton.addActionListener;). Can anyone point me in the right direction?





import java.util.*;
import java.swing.*;
import java.awt.*;
import java.event.*;

public class JRS_WK1 extends JFrame implements ActionListener
{//1
JButton myButton;

public static void main(String[]args)
{//2
GUI_JButton_Listener buttonGui = new GUI_JBtutton_Listener();
buttonGui.go();
}//1

//Declare variables
double a, t, i, p;//variables that will be used
JLabel amountLb1, termLb1, interestLb1, paymentLb1;//create labels
JTextField amountTf, termTf, interestTf, paymentsTf;//create text fields
JButton mybutton;// creats a button
JFrame myframe = new JFrame();// makes the frame
JButton myButton = new JButton("Calculate");
myButton.addActionListener;
myFrame.getContentPane().add(myButton);
myFrame.setsize(250,250);
myFrame.setVisible(true);

//Construction of rows in the panel
amountLb1 = new JLabel("Principle");
termLb1 = new JLabel("Term of loan");
interestLb1 = new JLabel("Interest Rate");
paymentLb1 = new JLabel("Monthly Payment");
amountTf = new JTextField();
termTf = new JTextField();
interestTf = new JTextField();
paymentTf = new JTextField();
myButton = new JButton("Calculate");

//Construction of the panel
myFrame = new JFrame("Mortgage Calculato");
myFrame.add(amountLb1);
myFrame.add(amountTf);
myFrame.add(termLb1);
myFrame.add(termTf);
myFrame.add(interestLb1);
myFrame.add(interestTf);
myFrame.add(paymentLb1);
myFrame.add(paymentTf);
myFrame.add(myButton);

}//2
Mar 17 '07 #2
r035198x
13,262 8TB
I keep getting and error message (<identifier> expected
myButton.addActionListener;). Can anyone point me in the right direction?





import java.util.*;
import java.swing.*;
import java.awt.*;
import java.event.*;

public class JRS_WK1 extends JFrame implements ActionListener
{//1
JButton myButton;

public static void main(String[]args)
{//2
GUI_JButton_Listener buttonGui = new GUI_JBtutton_Listener();
buttonGui.go();
}//1

//Declare variables
double a, t, i, p;//variables that will be used
JLabel amountLb1, termLb1, interestLb1, paymentLb1;//create labels
JTextField amountTf, termTf, interestTf, paymentsTf;//create text fields
JButton mybutton;// creats a button
JFrame myframe = new JFrame();// makes the frame
JButton myButton = new JButton("Calculate");
myButton.addActionListener;
myFrame.getContentPane().add(myButton);
myFrame.setsize(250,250);
myFrame.setVisible(true);

//Construction of rows in the panel
amountLb1 = new JLabel("Principle");
termLb1 = new JLabel("Term of loan");
interestLb1 = new JLabel("Interest Rate");
paymentLb1 = new JLabel("Monthly Payment");
amountTf = new JTextField();
termTf = new JTextField();
interestTf = new JTextField();
paymentTf = new JTextField();
myButton = new JButton("Calculate");

//Construction of the panel
myFrame = new JFrame("Mortgage Calculato");
myFrame.add(amountLb1);
myFrame.add(amountTf);
myFrame.add(termLb1);
myFrame.add(termTf);
myFrame.add(interestLb1);
myFrame.add(interestTf);
myFrame.add(paymentLb1);
myFrame.add(paymentTf);
myFrame.add(myButton);

}//2
In
Expand|Select|Wrap|Line Numbers
  1.  myButton.addActionListener;
  2.  
addActionListener is a method which takes an ActionListener as an Argument. An ActionListener is any class that implements the ActionListener interface. In your code, the class JRS_WK1 implements ActionListener interface so you can use

Expand|Select|Wrap|Line Numbers
  1. myButton.addActionListener(this);
. Then you would have to write the actionPerformed method in that class because implementing an interface means means that yiou are going to provide all the methods of that interface.
Mar 17 '07 #3
Ok, I tried the (this) thing and still getting the error message. I'm new to this so it is going to take a few tries to get it right!
Mar 17 '07 #4
r035198x
13,262 8TB
Ok, I tried the (this) thing and still getting the error message. I'm new to this so it is going to take a few tries to get it right!
Did you try all that I suggested? After adding the this thing I told you to do something else after that.
Mar 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: | last post by:
I am accessing the same error-containing ASP page on an ISP server using w2k IE6 but with different effect. On the first computer I get several line of HTML outputed by ASP, shown correctly by...
9
by: Mairhtin O'Feannag | last post by:
Hello, We have two machines we wish to use DPF. They are both RH ES 2.1, with DB2 8.2. I read the documentation CAREFULLY, and added the following line to my db2nodes.cfg file : 1 egret 0
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
10
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an...
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.