| | |
Abstract Error Message
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2005
Posts: 17
Reputation:
Solved Threads: 0
//JavaAirlinesApplet.java ERROR MESSAGE:
I would appreciate any help (I am very much a beginner in Java) what is this error message and also do I use init() or main() for applet?
Thank you so much
/*JavaAirlinesApplet.java:8: JavaAirlinesApplet is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class JavaAirlinesApplet extends JApplet
^
1 error*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.text.NumberFormat;
public class JavaAirlinesApplet extends JApplet
implements ActionListener
{
JTextField jtfMessage = new JTextField(20); //created message,label,2radio, button
JLabel jlblPassenger = new JLabel("Enter passenger name");
public JRadioButton jrbCessna, jrb747;
public JRadioButton jrbfirst, jrbsecond;
public JRadioButton jrbVeggie, jrbFish, jrbBeef;
JButton jbtPrintTicket = new JButton("Print Ticket");
public void init()// static void main(String[] args)
{
JFrame JavaAirlines = new JFrame("JavaAirlines");
JavaAirlines.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JavaAirlines.setTitle("JavaAirlines");
JavaAirlines.setSize(500, 200);
JavaAirlines.setVisible(true);
}
public void JavaAirlines()
{ //created message,label, 2 radio, button
JPanel jpTextField = new JPanel();
jpTextField.setLayout(new BorderLayout(1,2));
jpTextField.add(
new JLabel("Enter passenger name"), BorderLayout.WEST);
jpTextField.add(jtfMessage, BorderLayout.CENTER);
getContentPane().add(jpTextField, BorderLayout.NORTH);
jtfMessage.setHorizontalAlignment(JTextField.RIGHT);
JPanel jpRadioButtons = new JPanel();
jpRadioButtons.setLayout(new GridLayout(2, 2));
jpRadioButtons.add(jrbCessna = new JRadioButton("Cessna"));
jpRadioButtons.add(jrb747 = new JRadioButton("747"));
jpRadioButtons.add(jrbfirst = new JRadioButton("747 First Class"));
jpRadioButtons.add(jrbsecond = new JRadioButton("747 Second Class"));
//JPanel jpRadioButtons = new JPanel();
jpRadioButtons.setLayout(new GridLayout(3, 1));
jpRadioButtons.add(jrbVeggie = new JRadioButton("747 Veggie"));
jpRadioButtons.add(jrbFish = new JRadioButton("747 Fish"));
jpRadioButtons.add(jrbBeef = new JRadioButton("747 Beef"));
getContentPane().add(jbtPrintTicket, BorderLayout.SOUTH);
// Create a radio button group to group buttons
ButtonGroup group1 = new ButtonGroup();
group1.add(jrbCessna);
group1.add(jrb747);
group1.add(jrbfirst);
group1.add(jrbsecond);
ButtonGroup group2 = new ButtonGroup();
group2.add(jrbVeggie);
group2.add(jrbFish);
group2.add(jrbBeef);
// Register listeners //created message,2 radio, button
jtfMessage.addActionListener(this);
//jlblPassenger.addActionListener(this); //this line causes error
jrbCessna.addActionListener(this);
jrb747.addActionListener(this);
jrbfirst.addActionListener(this);
jrbsecond.addActionListener(this);
jrbVeggie.addActionListener(this);
jrbFish.addActionListener(this);
jrbBeef.addActionListener(this);
jbtPrintTicket.addActionListener(this);
ButtonListener btListener = new ButtonListener();
JPanel pa = new JPanel();
}
class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e){
System.out.println("Print Ticket");
}
}
}
I would appreciate any help (I am very much a beginner in Java) what is this error message and also do I use init() or main() for applet?
Thank you so much
/*JavaAirlinesApplet.java:8: JavaAirlinesApplet is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class JavaAirlinesApplet extends JApplet
^
1 error*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.text.NumberFormat;
public class JavaAirlinesApplet extends JApplet
implements ActionListener
{
JTextField jtfMessage = new JTextField(20); //created message,label,2radio, button
JLabel jlblPassenger = new JLabel("Enter passenger name");
public JRadioButton jrbCessna, jrb747;
public JRadioButton jrbfirst, jrbsecond;
public JRadioButton jrbVeggie, jrbFish, jrbBeef;
JButton jbtPrintTicket = new JButton("Print Ticket");
public void init()// static void main(String[] args)
{
JFrame JavaAirlines = new JFrame("JavaAirlines");
JavaAirlines.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JavaAirlines.setTitle("JavaAirlines");
JavaAirlines.setSize(500, 200);
JavaAirlines.setVisible(true);
}
public void JavaAirlines()
{ //created message,label, 2 radio, button
JPanel jpTextField = new JPanel();
jpTextField.setLayout(new BorderLayout(1,2));
jpTextField.add(
new JLabel("Enter passenger name"), BorderLayout.WEST);
jpTextField.add(jtfMessage, BorderLayout.CENTER);
getContentPane().add(jpTextField, BorderLayout.NORTH);
jtfMessage.setHorizontalAlignment(JTextField.RIGHT);
JPanel jpRadioButtons = new JPanel();
jpRadioButtons.setLayout(new GridLayout(2, 2));
jpRadioButtons.add(jrbCessna = new JRadioButton("Cessna"));
jpRadioButtons.add(jrb747 = new JRadioButton("747"));
jpRadioButtons.add(jrbfirst = new JRadioButton("747 First Class"));
jpRadioButtons.add(jrbsecond = new JRadioButton("747 Second Class"));
//JPanel jpRadioButtons = new JPanel();
jpRadioButtons.setLayout(new GridLayout(3, 1));
jpRadioButtons.add(jrbVeggie = new JRadioButton("747 Veggie"));
jpRadioButtons.add(jrbFish = new JRadioButton("747 Fish"));
jpRadioButtons.add(jrbBeef = new JRadioButton("747 Beef"));
getContentPane().add(jbtPrintTicket, BorderLayout.SOUTH);
// Create a radio button group to group buttons
ButtonGroup group1 = new ButtonGroup();
group1.add(jrbCessna);
group1.add(jrb747);
group1.add(jrbfirst);
group1.add(jrbsecond);
ButtonGroup group2 = new ButtonGroup();
group2.add(jrbVeggie);
group2.add(jrbFish);
group2.add(jrbBeef);
// Register listeners //created message,2 radio, button
jtfMessage.addActionListener(this);
//jlblPassenger.addActionListener(this); //this line causes error
jrbCessna.addActionListener(this);
jrb747.addActionListener(this);
jrbfirst.addActionListener(this);
jrbsecond.addActionListener(this);
jrbVeggie.addActionListener(this);
jrbFish.addActionListener(this);
jrbBeef.addActionListener(this);
jbtPrintTicket.addActionListener(this);
ButtonListener btListener = new ButtonListener();
JPanel pa = new JPanel();
}
class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e){
System.out.println("Print Ticket");
}
}
}
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
Hi everyone,
This is happening because of the declaration of the class
You cannot implement ActionListener if you do not have this function in your class
You have to insert the above function in your applet class or not implement it at all
and have a alternative system for receiving listeners for your applet
I hoped this has helped you
Yours Sincerely
Richard West
This is happening because of the declaration of the class
Java Syntax (Toggle Plain Text)
public class JavaAirlinesApplet extends JApplet implements ActionListener
You cannot implement ActionListener if you do not have this function in your class
Java Syntax (Toggle Plain Text)
public void actionPerformed(ActionEvent e) { }
You have to insert the above function in your applet class or not implement it at all
and have a alternative system for receiving listeners for your applet
I hoped this has helped you
Yours Sincerely
Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
•
•
Join Date: May 2005
Posts: 55
Reputation:
Solved Threads: 1
This is an simple example on implementing the ActionListener interface.
By looking at your code, this method actionPerformed will be called whenever the controls fire an action. I'm not sure if this is what you want. What are you trying to do anyways?
Also, you have a method called public void JavaAirlines(). This is not the constructor and I don't see it being called anywhere in your code.
For more help, www.NeedProgrammingHelp.com
Java Syntax (Toggle Plain Text)
class MyClass implements ActionListener { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "ACTION!"); } }
By looking at your code, this method actionPerformed will be called whenever the controls fire an action. I'm not sure if this is what you want. What are you trying to do anyways?
Also, you have a method called public void JavaAirlines(). This is not the constructor and I don't see it being called anywhere in your code.
For more help, www.NeedProgrammingHelp.com
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
Hi everyone,
Try this kitty
I compiled it and it compiles without errors but you really need to clean up your'
code and try to go to Sun's site and learn about the different listeners they have. The tutorials over there are very good
Yours Sincerely
Richard West
Try this kitty
Java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.TitledBorder; import java.text.NumberFormat; public class JavaAirlinesApplet extends JApplet implements ActionListener { public void actionPerformed(ActionEvent e) { } JTextField jtfMessage = new JTextField(20); //created message,label,2radio, button JLabel jlblPassenger = new JLabel("Enter passenger name"); public JRadioButton jrbCessna, jrb747; public JRadioButton jrbfirst, jrbsecond; public JRadioButton jrbVeggie, jrbFish, jrbBeef; JButton jbtPrintTicket = new JButton("Print Ticket"); public void init()// static void main(String[] args) { JFrame JavaAirlines = new JFrame("JavaAirlines"); JavaAirlines.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JavaAirlines.setTitle("JavaAirlines"); JavaAirlines.setSize(500, 200); JavaAirlines.setVisible(true); } public void JavaAirlines() { //created message,label, 2 radio, button JPanel jpTextField = new JPanel(); jpTextField.setLayout(new BorderLayout(1,2)); jpTextField.add( new JLabel("Enter passenger name"), BorderLayout.WEST); jpTextField.add(jtfMessage, BorderLayout.CENTER); getContentPane().add(jpTextField, BorderLayout.NORTH); jtfMessage.setHorizontalAlignment(JTextField.RIGHT); JPanel jpRadioButtons = new JPanel(); jpRadioButtons.setLayout(new GridLayout(2, 2)); jpRadioButtons.add(jrbCessna = new JRadioButton("Cessna")); jpRadioButtons.add(jrb747 = new JRadioButton("747")); jpRadioButtons.add(jrbfirst = new JRadioButton("747 First Class")); jpRadioButtons.add(jrbsecond = new JRadioButton("747 Second Class")); //JPanel jpRadioButtons = new JPanel(); jpRadioButtons.setLayout(new GridLayout(3, 1)); jpRadioButtons.add(jrbVeggie = new JRadioButton("747 Veggie")); jpRadioButtons.add(jrbFish = new JRadioButton("747 Fish")); jpRadioButtons.add(jrbBeef = new JRadioButton("747 Beef")); getContentPane().add(jbtPrintTicket, BorderLayout.SOUTH); // Create a radio button group to group buttons ButtonGroup group1 = new ButtonGroup(); group1.add(jrbCessna); group1.add(jrb747); group1.add(jrbfirst); group1.add(jrbsecond); ButtonGroup group2 = new ButtonGroup(); group2.add(jrbVeggie); group2.add(jrbFish); group2.add(jrbBeef); // Register listeners //created message,2 radio, button jtfMessage.addActionListener(this); //jlblPassenger.addActionListener(this); //this line causes error jrbCessna.addActionListener(this); jrb747.addActionListener(this); jrbfirst.addActionListener(this); jrbsecond.addActionListener(this); jrbVeggie.addActionListener(this); jrbFish.addActionListener(this); jrbBeef.addActionListener(this); jbtPrintTicket.addActionListener(this); ButtonListener btListener = new ButtonListener(); JPanel pa = new JPanel(); } class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e){ System.out.println("Print Ticket"); } } }
I compiled it and it compiles without errors but you really need to clean up your'
code and try to go to Sun's site and learn about the different listeners they have. The tutorials over there are very good
Yours Sincerely
Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
•
•
Join Date: Apr 2005
Posts: 17
Reputation:
Solved Threads: 0
Hi Thanks for all your help but now that I got it to compile, the applet does not initialize.
The program is supposed to be an Applet GUI with labels, radio buttons, etc for flight and food choices for passengers.
Thanks again, Kittie
//JavaAirlinesApplet3.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.text.NumberFormat;
public class JavaAirlinesApplet3 extends JApplet implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, "Your flight is booked");
}
JTextField jtfMessage = new JTextField(20);
JLabel jlblPassenger = new JLabel("Enter passenger name");
public JRadioButton jrbCessna, jrb747;
public JRadioButton jrbfirst, jrbsecond;
public JRadioButton jrbVeggie, jrbFish, jrbBeef;
JButton jbtPrintTicket = new JButton("Print Ticket");
public void init()
{
JFrame JavaAirlines = new JFrame("JavaAirlines");
JavaAirlines.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JavaAirlines.setTitle("JavaAirlines");
JavaAirlines.setSize(500, 200); JavaAirlines.setVisible(true);
}
public void JavaAirlines3()
{
JPanel jpTextField = new JPanel();
jpTextField.setLayout(new BorderLayout(1,2));
jpTextField.add( new JLabel("Enter passenger name"), BorderLayout.WEST);
jpTextField.add(jtfMessage, BorderLayout.CENTER);
getContentPane().add(jpTextField, BorderLayout.NORTH);
jtfMessage.setHorizontalAlignment(JTextField.RIGHT);
JPanel jpRadioButtons = new JPanel();
jpRadioButtons.setLayout(new GridLayout(2, 2));
jpRadioButtons.add(jrbCessna = new JRadioButton("Cessna"));
jpRadioButtons.add(jrb747 = new JRadioButton("747"));
jpRadioButtons.add(jrbfirst = new JRadioButton("747 First Class"));
jpRadioButtons.add(jrbsecond = new JRadioButton("747 Second Class"));
//JPanel jpRadioButtons = new JPanel();
jpRadioButtons.setLayout(new GridLayout(3, 1));
jpRadioButtons.add(jrbVeggie = new JRadioButton("747 Veggie"));
jpRadioButtons.add(jrbFish = new JRadioButton("747 Fish"));
jpRadioButtons.add(jrbBeef = new JRadioButton("747 Beef"));
getContentPane().add(jbtPrintTicket, BorderLayout.SOUTH);
ButtonGroup group1 = new ButtonGroup();
group1.add(jrbCessna); group1.add(jrb747);
group1.add(jrbfirst); group1.add(jrbsecond);
ButtonGroup group2 = new ButtonGroup();
group2.add(jrbVeggie); group2.add(jrbFish);
group2.add(jrbBeef);
// Register listeners
jtfMessage.addActionListener(this);
//jlblPassenger.addActionListener(this); //this line causes error
jrbCessna.addActionListener(this);
jrb747.addActionListener(this);
jrbfirst.addActionListener(this);
jrbsecond.addActionListener(this);
jrbVeggie.addActionListener(this);
jrbFish.addActionListener(this);
jrbBeef.addActionListener(this);
jbtPrintTicket.addActionListener(this);
ButtonListener btListener = new ButtonListener();
JPanel pa = new JPanel();
}
class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.out.println("Print Ticket");
} } }
The program is supposed to be an Applet GUI with labels, radio buttons, etc for flight and food choices for passengers.
Thanks again, Kittie
//JavaAirlinesApplet3.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.text.NumberFormat;
public class JavaAirlinesApplet3 extends JApplet implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, "Your flight is booked");
}
JTextField jtfMessage = new JTextField(20);
JLabel jlblPassenger = new JLabel("Enter passenger name");
public JRadioButton jrbCessna, jrb747;
public JRadioButton jrbfirst, jrbsecond;
public JRadioButton jrbVeggie, jrbFish, jrbBeef;
JButton jbtPrintTicket = new JButton("Print Ticket");
public void init()
{
JFrame JavaAirlines = new JFrame("JavaAirlines");
JavaAirlines.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JavaAirlines.setTitle("JavaAirlines");
JavaAirlines.setSize(500, 200); JavaAirlines.setVisible(true);
}
public void JavaAirlines3()
{
JPanel jpTextField = new JPanel();
jpTextField.setLayout(new BorderLayout(1,2));
jpTextField.add( new JLabel("Enter passenger name"), BorderLayout.WEST);
jpTextField.add(jtfMessage, BorderLayout.CENTER);
getContentPane().add(jpTextField, BorderLayout.NORTH);
jtfMessage.setHorizontalAlignment(JTextField.RIGHT);
JPanel jpRadioButtons = new JPanel();
jpRadioButtons.setLayout(new GridLayout(2, 2));
jpRadioButtons.add(jrbCessna = new JRadioButton("Cessna"));
jpRadioButtons.add(jrb747 = new JRadioButton("747"));
jpRadioButtons.add(jrbfirst = new JRadioButton("747 First Class"));
jpRadioButtons.add(jrbsecond = new JRadioButton("747 Second Class"));
//JPanel jpRadioButtons = new JPanel();
jpRadioButtons.setLayout(new GridLayout(3, 1));
jpRadioButtons.add(jrbVeggie = new JRadioButton("747 Veggie"));
jpRadioButtons.add(jrbFish = new JRadioButton("747 Fish"));
jpRadioButtons.add(jrbBeef = new JRadioButton("747 Beef"));
getContentPane().add(jbtPrintTicket, BorderLayout.SOUTH);
ButtonGroup group1 = new ButtonGroup();
group1.add(jrbCessna); group1.add(jrb747);
group1.add(jrbfirst); group1.add(jrbsecond);
ButtonGroup group2 = new ButtonGroup();
group2.add(jrbVeggie); group2.add(jrbFish);
group2.add(jrbBeef);
// Register listeners
jtfMessage.addActionListener(this);
//jlblPassenger.addActionListener(this); //this line causes error
jrbCessna.addActionListener(this);
jrb747.addActionListener(this);
jrbfirst.addActionListener(this);
jrbsecond.addActionListener(this);
jrbVeggie.addActionListener(this);
jrbFish.addActionListener(this);
jrbBeef.addActionListener(this);
jbtPrintTicket.addActionListener(this);
ButtonListener btListener = new ButtonListener();
JPanel pa = new JPanel();
}
class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.out.println("Print Ticket");
} } }
•
•
Join Date: May 2005
Posts: 55
Reputation:
Solved Threads: 1
I believe, the method public void JavaAirlines3() is not being called. This method is the one that puts all the radio buttons, etc. into your frame.
Call this method from your init() method.
For more help, www.NeedProgrammingHelp.com
Call this method from your init() method.
For more help, www.NeedProgrammingHelp.com
•
•
Join Date: May 2005
Posts: 55
Reputation:
Solved Threads: 1
How are you running the applet? Are you using the applet viewer or using IE? Try to use the applet viewer and it should give some error messages.
To use the applet viewer, go into the command prompt and go to the directory of your .html file and write
replace nameOfHtmlFile with the correct name. Post any errors here.
For more help, www.NeedProgrammingHelp.com
To use the applet viewer, go into the command prompt and go to the directory of your .html file and write
Java Syntax (Toggle Plain Text)
appletviewer nameOfHtmlFile.html
replace nameOfHtmlFile with the correct name. Post any errors here.
For more help, www.NeedProgrammingHelp.com
![]() |
Similar Threads
- Toshiba IDE1 error message (Windows NT / 2000 / XP)
- MERGED: Hardware/Driver Problems-Error Message (Windows 95 / 98 / Me)
- wupdater.exe error message (Web Browsers)
- Please help with DLL error message! (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: I Need Help!!
- Next Thread: Objects
Views: 5354 | Replies: 16
| Thread Tools | Search this Thread |
Tag cloud for Java
911 addressbook android api append apple applet application arguments array arrays automation binary bluetooth character chat class classes client code component csv database draw eclipse error event exception file fractal ftp game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me japplet java javaarraylist javaprojects jmf jni jpanel julia linked linux list loop map method methods mobile netbeans newbie number object objects oracle oriented panel print printf problem program programming project projects recursion replaydirector reporting researchinmotion return robot rotatetext scanner screen se server set size sms socket sort sql stream string swing test threads time transfer tree ubuntu windows





