Results 1 to 3 of 3
Thread: Event handling... help?
- 04-04-2009, 01:00 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 30
- Rep Power
- 0
Event handling... help?
I'm trying to add events in my program. Here is my code:
But if I add "implements ActionListener" at the end of the class name like this:Java Code:import java.io.*; import java.awt.*; import java.awt.event.*; public class MainProgram { String name0x1; TravellingPackage prog[] = new TravellingPackage[10]; Frame phi; Button beta; Choice tau; TextField alpha1, alpha2, alpha3, nu, chi; Label lambda, lambda2, theta1, theta2, theta3, theta3a, theta3b, theta3c, theta4; Panel header, pi, pi2, pi3, pi3a, pi4, pi5, footer; public static void main (String args[]) throws IOException { MainProgram main = new MainProgram(); main.addComponents(); } public void addComponents() { File data = new File ("report.txt"); int q = 0; phi = new Frame("MKDL Travel Agency System Ver. I"); phi.setLayout(null); phi.setSize(500,500); phi.setResizable(false); phi.setLocation(100,100); phi.setBackground(Color.gray); header = new Panel(); pi = new Panel(); pi2 = new Panel(); pi3 = new Panel(); pi3a = new Panel(); pi4 = new Panel(); pi5 = new Panel(); footer = new Panel(); header.setSize(400,50); header.setLocation(50,50); header.setBackground(Color.orange); pi.setSize(400,50); pi.setLocation(50,100); pi.setBackground(Color.blue); pi2.setSize(400,50); pi2.setLocation(50,150); pi2.setBackground(Color.red); pi3.setSize(400,50); pi3.setLocation(50,200); pi3.setBackground(Color.yellow); pi3a.setSize(400,50); pi3a.setLocation(50,250); pi3a.setBackground(Color.yellow); pi4.setSize(400,50); pi4.setLocation(50,300); pi4.setBackground(Color.magenta); pi5.setSize(400,50); pi5.setLocation(50,350); pi5.setBackground(Color.green); footer.setSize(400,50); footer.setLocation(50,400); footer.setBackground(Color.pink); beta = new Button("Calculate Fare"); tau = new Choice(); lambda = new Label("MKDL Travel Agency System Ver. I"); lambda2 = new Label("(C) 2009 MKDL Studios. All rights reserved."); alpha1 = new TextField("",2); alpha2 = new TextField("",2); alpha3 = new TextField("",2); theta1 = new Label("Agent's Name"); theta2 = new Label("Travelling Method"); theta3 = new Label("Number of Tourists"); theta3a = new Label("Age Below 2"); theta3b = new Label("Age 2-16"); theta3c = new Label("Age Above 16"); theta4 = new Label("Total Fare:"); nu = new TextField("",30); chi = new TextField("",20); tau.add("Bus"); tau.add("Cruise"); tau.add("Airplane"); beta = new Button("Calculate Fare"); header.add(lambda); pi.add(theta1); pi.add(nu); pi2.add(theta2); pi2.add(tau); pi3.add(theta3); pi3a.add(theta3a); pi3a.add(alpha1); pi3a.add(theta3b); pi3a.add(alpha2); pi3a.add(theta3c); pi3a.add(alpha3); pi4.add(beta); pi5.add(theta4); pi5.add(chi); footer.add(lambda2); phi.add(header); phi.add(pi); phi.add(pi2); phi.add(pi3); phi.add(pi3a); phi.add(pi4); phi.add(pi5); phi.add(footer); phi.setVisible(true); } }
an error message is displayed:Java Code:public class MainProgram implements ActionListener
What should I do??Java Code:--------------------Configuration: <Default>-------------------- E:\mkdl\archive1\jp219\MainProgram.java:5: MainProgram is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener public class MainProgram implements ActionListener ^ 1 error Process completed.
- 04-04-2009, 03:59 PM #2
-
Similar Threads
-
Event handling in JSF
By java08 in forum JavaServer Faces (JSF)Replies: 0Last Post: 03-24-2009, 06:42 AM -
rmi and event handling
By darkhorse in forum Advanced JavaReplies: 0Last Post: 03-15-2009, 08:20 AM -
SWT Event Handling
By Java Tip in forum Java TipReplies: 0Last Post: 12-30-2007, 12:21 PM -
problem with event handling!!!
By ahdus in forum Java AppletsReplies: 1Last Post: 11-17-2007, 06:24 PM -
Event Handling
By luisarca in forum Sun Java Wireless ToolkitReplies: 5Last Post: 05-07-2007, 06:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks