Abstract Error Message

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2005
Posts: 17
Reputation: kittie is an unknown quantity at this point 
Solved Threads: 0
kittie kittie is offline Offline
Newbie Poster

Abstract Error Message

 
0
  #1
Aug 12th, 2005
//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");
}
}
}
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 8
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: Abstract Error Message

 
0
  #2
Aug 12th, 2005
Hi everyone,

This is happening because of the declaration of the class
  1. public class JavaAirlinesApplet extends JApplet
  2. implements ActionListener

You cannot implement ActionListener if you do not have this function in your class
  1. public void actionPerformed(ActionEvent e)
  2. {
  3. }

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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 17
Reputation: kittie is an unknown quantity at this point 
Solved Threads: 0
kittie kittie is offline Offline
Newbie Poster

Re: Abstract Error Message

 
0
  #3
Aug 12th, 2005
THanks for your help but no matter where I move braces or that function I get errors. Can you tell me exactly where to put it and what is wrong with my braces?

I really appreciate it Kittie
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 17
Reputation: kittie is an unknown quantity at this point 
Solved Threads: 0
kittie kittie is offline Offline
Newbie Poster

Re: Abstract Error Message

 
0
  #4
Aug 12th, 2005
THanks for your help but no matter where I move braces or that function I get errors. Can you tell me exactly where to put it and what is wrong with my braces?

I really appreciate it Kittie
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 55
Reputation: NPH is an unknown quantity at this point 
Solved Threads: 1
NPH NPH is offline Offline
Junior Poster in Training

Re: Abstract Error Message

 
0
  #5
Aug 12th, 2005
This is an simple example on implementing the ActionListener interface.

  1. class MyClass implements ActionListener
  2. {
  3.  
  4. public void actionPerformed(ActionEvent e)
  5. {
  6. JOptionPane.showMessageDialog(null, "ACTION!");
  7. }
  8. }

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
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 8
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: Abstract Error Message

 
0
  #6
Aug 12th, 2005
Hi everyone,

Try this kitty

  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import javax.swing.border.TitledBorder;
  5. import java.text.NumberFormat;
  6.  
  7. public class JavaAirlinesApplet extends JApplet
  8. implements ActionListener
  9. {
  10.  
  11. public void actionPerformed(ActionEvent e)
  12. {
  13.  
  14. }
  15.  
  16. JTextField jtfMessage = new JTextField(20); //created message,label,2radio, button
  17. JLabel jlblPassenger = new JLabel("Enter passenger name");
  18.  
  19. public JRadioButton jrbCessna, jrb747;
  20. public JRadioButton jrbfirst, jrbsecond;
  21. public JRadioButton jrbVeggie, jrbFish, jrbBeef;
  22.  
  23. JButton jbtPrintTicket = new JButton("Print Ticket");
  24.  
  25. public void init()// static void main(String[] args)
  26. {
  27. JFrame JavaAirlines = new JFrame("JavaAirlines");
  28. JavaAirlines.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  29. JavaAirlines.setTitle("JavaAirlines");
  30. JavaAirlines.setSize(500, 200);
  31. JavaAirlines.setVisible(true);
  32.  
  33. }
  34. public void JavaAirlines()
  35. { //created message,label, 2 radio, button
  36. JPanel jpTextField = new JPanel();
  37. jpTextField.setLayout(new BorderLayout(1,2));
  38. jpTextField.add(
  39. new JLabel("Enter passenger name"), BorderLayout.WEST);
  40. jpTextField.add(jtfMessage, BorderLayout.CENTER);
  41. getContentPane().add(jpTextField, BorderLayout.NORTH);
  42. jtfMessage.setHorizontalAlignment(JTextField.RIGHT);
  43.  
  44. JPanel jpRadioButtons = new JPanel();
  45. jpRadioButtons.setLayout(new GridLayout(2, 2));
  46. jpRadioButtons.add(jrbCessna = new JRadioButton("Cessna"));
  47. jpRadioButtons.add(jrb747 = new JRadioButton("747"));
  48. jpRadioButtons.add(jrbfirst = new JRadioButton("747 First Class"));
  49. jpRadioButtons.add(jrbsecond = new JRadioButton("747 Second Class"));
  50.  
  51. //JPanel jpRadioButtons = new JPanel();
  52. jpRadioButtons.setLayout(new GridLayout(3, 1));
  53. jpRadioButtons.add(jrbVeggie = new JRadioButton("747 Veggie"));
  54. jpRadioButtons.add(jrbFish = new JRadioButton("747 Fish"));
  55. jpRadioButtons.add(jrbBeef = new JRadioButton("747 Beef"));
  56.  
  57. getContentPane().add(jbtPrintTicket, BorderLayout.SOUTH);
  58.  
  59. // Create a radio button group to group buttons
  60. ButtonGroup group1 = new ButtonGroup();
  61. group1.add(jrbCessna);
  62. group1.add(jrb747);
  63. group1.add(jrbfirst);
  64. group1.add(jrbsecond);
  65.  
  66. ButtonGroup group2 = new ButtonGroup();
  67. group2.add(jrbVeggie);
  68. group2.add(jrbFish);
  69. group2.add(jrbBeef);
  70.  
  71. // Register listeners //created message,2 radio, button
  72. jtfMessage.addActionListener(this);
  73. //jlblPassenger.addActionListener(this); //this line causes error
  74.  
  75. jrbCessna.addActionListener(this);
  76. jrb747.addActionListener(this);
  77. jrbfirst.addActionListener(this);
  78. jrbsecond.addActionListener(this);
  79.  
  80. jrbVeggie.addActionListener(this);
  81. jrbFish.addActionListener(this);
  82. jrbBeef.addActionListener(this);
  83.  
  84. jbtPrintTicket.addActionListener(this);
  85.  
  86. ButtonListener btListener = new ButtonListener();
  87. JPanel pa = new JPanel();
  88. }
  89. class ButtonListener implements ActionListener {
  90. public void actionPerformed(ActionEvent e){
  91. System.out.println("Print Ticket");
  92. }
  93. }
  94. }

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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 17
Reputation: kittie is an unknown quantity at this point 
Solved Threads: 0
kittie kittie is offline Offline
Newbie Poster

Re: Applet not initializing

 
0
  #7
Aug 12th, 2005
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");
} } }
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 55
Reputation: NPH is an unknown quantity at this point 
Solved Threads: 1
NPH NPH is offline Offline
Junior Poster in Training

Re: Abstract Error Message

 
0
  #8
Aug 12th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 17
Reputation: kittie is an unknown quantity at this point 
Solved Threads: 0
kittie kittie is offline Offline
Newbie Poster

Re: Abstract Error Message

 
0
  #9
Aug 12th, 2005
Thanks NPH
I put JavaAirlines3(); at the end of the init() but it still says Applet not initialized.
I really appreciate your help, Kittie
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 55
Reputation: NPH is an unknown quantity at this point 
Solved Threads: 1
NPH NPH is offline Offline
Junior Poster in Training

Re: Abstract Error Message

 
0
  #10
Aug 12th, 2005
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

  1. appletviewer nameOfHtmlFile.html

replace nameOfHtmlFile with the correct name. Post any errors here.

For more help, www.NeedProgrammingHelp.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 5354 | Replies: 16
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC