i need urgent help. this error cmoing. i dont know what to do

Reply

Join Date: May 2008
Posts: 65
Reputation: lich has a little shameless behaviour in the past 
Solved Threads: 4
lich lich is offline Offline
Junior Poster in Training

i need urgent help. this error cmoing. i dont know what to do

 
-1
  #1
Aug 9th, 2008
  1. import java.awt.*;
  2. import java.applet.*;
  3. import java.awt.event.*;
  4.  
  5. public class hashedited extends Applet implements ItemListener
  6. {
  7. CheckboxGroup cbg;
  8. //CheckboxGroup type1,type2;
  9. //CheckboxGroup cbg1;
  10. //CheckboxGroup size1, size2;
  11.  
  12. private TextField amtpaid;
  13. private Button cancel;
  14. private Label cost;
  15. private Choice flavour;
  16. private Label flavours;
  17. private Label name;
  18. private Button ok;
  19. private Label paid;
  20. private Panel panel1;
  21. private Panel panel2;
  22. private Panel panel3;
  23. private Button price1;
  24. private Button price2;
  25. private Button price3;
  26. private Button price4;
  27. private Button price5;
  28. private Button price6;
  29. private Button price7;
  30. private Checkbox size1;
  31. private Checkbox size2;
  32. private Label sizename;
  33. private Button soda;
  34. private TextField totcost;
  35. private Checkbox type1;
  36. private Checkbox type2;
  37. private Label typename;
  38.  
  39. /** Initializes the applet project */
  40. public void init()
  41. {
  42. System.out.println("tedt");
  43.  
  44. cbg= new CheckboxGroup();
  45.  
  46.  
  47. name = new Label();
  48. ok = new Button();
  49. cancel = new Button();
  50. panel1 = new Panel();
  51. type1 = new Checkbox();
  52. type2 = new Checkbox();
  53. size1 = new Checkbox();
  54. size2 = new Checkbox();
  55. typename = new Label();
  56. sizename = new Label();
  57. flavours = new Label();
  58. flavour = new Choice();
  59. panel2 = new Panel();
  60. price1 = new Button();
  61. price2 = new Button();
  62. price3 = new Button();
  63. price4 = new Button();
  64. price5 = new Button();
  65. price6 = new Button();
  66. price7 = new Button();
  67. panel3 = new Panel();
  68. cost = new Label();
  69. totcost = new TextField();
  70. paid = new Label();
  71. amtpaid = new TextField();
  72. soda = new Button();
  73.  
  74. setBackground(new Color(0, 105, 0));
  75. setLayout(null);
  76.  
  77. name.setAlignment(Label.CENTER);
  78. name.setBackground(new Color(204, 255, 204));
  79. name.setFont(new Font("Algerian", 3, 24));
  80. name.setForeground(new Color(0, 0, 0));
  81. name.setText("TaStY SoDa");
  82. add(name);
  83. name.setBounds(20, 10, 630, 40);
  84. name.getAccessibleContext().setAccessibleName("TaStY SoDa");
  85.  
  86. ok.setBackground(new Color(153, 255, 153));
  87. ok.setFont(new Font("Arial", 3, 12));
  88. ok.setLabel("OK");
  89. add(ok);
  90. ok.setBounds(140, 250, 80, 23);
  91.  
  92. cancel.setBackground(new Color(153, 255, 153));
  93. cancel.setFont(new Font("Arial", 3, 12));
  94. cancel.setLabel("CANCEL");
  95. add(cancel);
  96. cancel.setBounds(262, 250, 80, 23);
  97.  
  98. panel1.setBackground(new Color(204, 255, 204));
  99. panel1.setLayout(null);
  100.  
  101. //cbg = new CheckboxGroup();
  102. type1.setFont(new Font("Century Gothic", 1, 14));
  103. type1 = new Checkbox("Regular",cbg,true);
  104. panel1.add(type1);
  105. type1.setBounds(130, 70, 90, 23);
  106. //type1.addItemListener(this);
  107.  
  108. //cbg = new CheckboxGroup();
  109. type2.setFont(new Font("Century Gothic", 1, 14));
  110. type2= new Checkbox("Diet",cbg,false);
  111. panel1.add(type2);
  112. type2.setBounds(280, 70, 53, 23);
  113. //type2.addItemListener(this);
  114.  
  115. type1.addItemListener(this);
  116. type2.addItemListener(this);
  117.  
  118. type1.addItemListener(new ItemListener() {
  119. public void itemStateChanged(ItemEvent evt) {
  120. type1ItemStateChanged(evt);
  121. }
  122. });
  123.  
  124. type2.addItemListener(new ItemListener() {
  125. public void itemStateChanged(ItemEvent evt) {
  126. type2ItemStateChanged(evt);
  127. }
  128. });
  129. //cbg1 = new CheckboxGroup();
  130. size1.setFont(new Font("Century Gothic", 1, 14));
  131. size1.setLabel("10 oz - (1.60 $)");
  132. panel1.add(size1);
  133. size1.setBounds(130, 110, 125, 23);
  134. //size1.addItemListener(this);
  135.  
  136. //cbg1 = new CheckboxGroup();
  137. size2.setFont(new Font("Century Gothic", 1, 14));
  138. size2.setLabel("16 oz - (2.00 $)");
  139. panel1.add(size2);
  140. size2.setBounds(280, 110, 125, 23);
  141. //size2.addItemListener(this);
  142.  
  143. typename.setAlignment(Label.CENTER);
  144. typename.setBackground(new Color(153, 255, 153));
  145. typename.setFont(new Font("Dialog", 1, 13));
  146. typename.setText("Type");
  147. panel1.add(typename);
  148. typename.setBounds(10, 70, 70, 22);
  149.  
  150. sizename.setAlignment(Label.CENTER);
  151. sizename.setBackground(new Color(153, 255, 153));
  152. sizename.setFont(new Font("Dialog", 1, 13));
  153. sizename.setText("Size");
  154. panel1.add(sizename);
  155. sizename.setBounds(10, 110, 70, 22);
  156.  
  157. flavours.setAlignment(Label.CENTER);
  158. flavours.setBackground(new Color(153, 255, 153));
  159. flavours.setFont(new Font("Arial", 1, 13));
  160. flavours.setForeground(new Color(0, 51, 51));
  161. flavours.setText("Flavours");
  162. panel1.add(flavours);
  163. flavours.setBounds(10, 20, 70, 19);
  164.  
  165. flavour.add("Cola");
  166. flavour.add("Orange");
  167. flavour.add("Lime");
  168. flavour.setFont(new Font("Candara", 0, 12));
  169. panel1.add(flavour);
  170. flavour.setBounds(130, 20, 180, 19);
  171.  
  172. add(panel1);
  173. panel1.setBounds(20, 80, 430, 150);
  174.  
  175. panel2.setBackground(new Color(204, 255, 204));
  176. panel2.setLayout(null);
  177.  
  178. price1.setBackground(new Color(153, 153, 0));
  179. price1.setFont(new Font("Dialog", 1, 12));
  180. price1.setLabel("10 cents");
  181. panel2.add(price1);
  182. price1.setBounds(40, 20, 70, 24);
  183.  
  184. price2.setBackground(new Color(153, 153, 0));
  185. price2.setFont(new Font("Dialog", 1, 12));
  186. price2.setLabel("20 cents");
  187. panel2.add(price2);
  188. price2.setBounds(40, 60, 70, 24);
  189.  
  190. price3.setBackground(new Color(153, 153, 0));
  191. price3.setFont(new Font("Dialog", 1, 12));
  192. price3.setLabel("50 cents");
  193. panel2.add(price3);
  194. price3.setBounds(40, 100, 70, 24);
  195.  
  196. price4.setBackground(new Color(153, 153, 0));
  197. price4.setFont(new Font("Dialog", 1, 12));
  198. price4.setLabel("1.00 $");
  199. panel2.add(price4);
  200. price4.setBounds(40, 140, 70, 24);
  201.  
  202. price5.setBackground(new Color(153, 153, 0));
  203. price5.setFont(new Font("Dialog", 1, 12));
  204. price5.setLabel("2.00 $");
  205. panel2.add(price5);
  206. price5.setBounds(40, 180, 70, 24);
  207.  
  208. price6.setBackground(new Color(153, 153, 0));
  209. price6.setFont(new Font("Dialog", 1, 12));
  210. price6.setLabel("5.00 $");
  211. panel2.add(price6);
  212. price6.setBounds(40, 220, 70, 24);
  213.  
  214. price7.setBackground(new Color(153, 153, 0));
  215. price7.setFont(new Font("Dialog", 1, 12));
  216. price7.setLabel("10.00 $");
  217. panel2.add(price7);
  218. price7.setBounds(40, 260, 70, 24);
  219.  
  220. add(panel2);
  221. panel2.setBounds(500, 100, 150, 300);
  222.  
  223. panel3.setBackground(new Color(204, 255, 204));
  224. panel3.setLayout(null);
  225.  
  226. cost.setAlignment(Label.CENTER);
  227. cost.setBackground(new Color(153, 255, 153));
  228. cost.setFont(new Font("Dialog", 1, 13));
  229. cost.setText("Total Cost");
  230. panel3.add(cost);
  231. cost.setBounds(10, 30, 80, 22);
  232.  
  233. totcost.setBackground(new Color(255, 255, 255));
  234. panel3.add(totcost);
  235. totcost.setBounds(150, 30, 120, 20);
  236.  
  237. paid.setAlignment(Label.CENTER);
  238. paid.setBackground(new Color(153, 255, 153));
  239. paid.setFont(new Font("Dialog", 1, 13));
  240. paid.setText("Amount Paid");
  241. panel3.add(paid);
  242. paid.setBounds(10, 70, 90, 22);
  243. panel3.add(amtpaid);
  244. amtpaid.setBounds(150, 70, 120, 20);
  245.  
  246. add(panel3);
  247. panel3.setBounds(70, 310, 330, 110);
  248.  
  249. soda.setBackground(new Color(153, 255, 153));
  250. soda.setFont(new Font("Arial", 3, 14));
  251. soda.setLabel("Take Soda and change");
  252.  
  253. soda.addActionListener(new ActionListener()
  254. {
  255. public void actionPerformed(ActionEvent evt)
  256. {
  257. sodaActionPerformed(evt);
  258. }
  259. });
  260. add(soda);
  261. soda.setBounds(130, 450, 210, 25);
  262. }// </editor-fold>
  263.  
  264. private void sodaActionPerformed(ActionEvent evt)
  265. {
  266. // TODO add your handling code here:
  267. /* if (flavour = "Lime")
  268.   {
  269.   type2.setVisible(false);
  270.   }
  271.  
  272.   else
  273.   {
  274.   type2.setVisible(true);
  275.   }*/
  276. System.out.println("test");
  277. }
  278. private void type1ItemStateChanged(ItemEvent evt)
  279. {
  280.  
  281. System.out.println("test");
  282. }
  283.  
  284. private void type2ItemStateChanged(ItemEvent evt)
  285. {
  286.  
  287. System.out.println("test2");
  288. }
  289.  
  290. public void actionPerformed(ActionEvent evt)
  291. {
  292. repaint();
  293. }
  294. public void paint(Graphics g)
  295. {
  296. System.out.println("test");
  297.  
  298.  
  299. }

C:\Documents and Settings\Lichâ„¢\Desktop\hashedited.java:5: hashedited is not abstract and does not override abstract method itemStateChanged(java.awt.event.ItemEvent) in java.awt.event.ItemListener
public class hashedited extends Applet implements ItemListener

Last edited by Ancient Dragon; Aug 9th, 2008 at 4:47 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,811
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: i need urgent help. this error cmoing. i dont know what to do

 
0
  #2
Aug 9th, 2008
Anytime you implement any type of Listener in Java, you need to implement at least one function. With ActionListener, it's "actionPerformed". With ItemListener, it's "itemStateChanged". Always type in "ItemListener", or whatever Listener you are using, into google, find a link that takes you to a Java documentation page, then scroll down to the "Method Summary" portion of the page. Make sure you have those functions in your program, even if they are empty.

http://java.sun.com/j2se/1.5.0/docs/...vent.ItemEvent)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 65
Reputation: lich has a little shameless behaviour in the past 
Solved Threads: 4
lich lich is offline Offline
Junior Poster in Training

Re: i need urgent help. this error cmoing. i dont know what to do

 
0
  #3
Aug 9th, 2008
Originally Posted by VernonDozier View Post
Anytime you implement any type of Listener in Java, you need to implement at least one function. With ActionListener, it's "actionPerformed". With ItemListener, it's "itemStateChanged". Always type in "ItemListener", or whatever Listener you are using, into google, find a link that takes you to a Java documentation page, then scroll down to the "Method Summary" portion of the page. Make sure you have those functions in your program, even if they are empty.

http://java.sun.com/j2se/1.5.0/docs/...vent.ItemEvent)

but i have put that two rite.. its there...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 408
Reputation: sciwizeh is on a distinguished road 
Solved Threads: 22
sciwizeh's Avatar
sciwizeh sciwizeh is offline Offline
Posting Pro in Training

Re: i need urgent help. this error cmoing. i dont know what to do

 
0
  #4
Aug 9th, 2008
take out ItemListener in your class statement and take out the .addItemListener(this) call,

the reason is that you are making an abstract item listener with the second set of calls to addItemListener, and your class isn't acting as the listener at all
My site, random PM's from people I haven't hear from before will be DELETED
"If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.",
"If we knew what it was we were doing, it would not be called research, would it? "
-Albert Einstein
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 5
Reputation: vigneswara is an unknown quantity at this point 
Solved Threads: 0
vigneswara vigneswara is offline Offline
Newbie Poster

Re: i need urgent help. this error cmoing. i dont know what to do

 
0
  #5
Aug 12th, 2008
ItemListener is an interface
u r class is implemented with ItemListener
once u implement the Listeners u must define the abstract methods
just declare those abstract methods
without define the abstract methods u got an error
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC