| | |
i need urgent help. this error cmoing. i dont know what to do
![]() |
•
•
Join Date: May 2008
Posts: 65
Reputation:
Solved Threads: 4
java Syntax (Toggle Plain Text)
import java.awt.*; import java.applet.*; import java.awt.event.*; public class hashedited extends Applet implements ItemListener { CheckboxGroup cbg; //CheckboxGroup type1,type2; //CheckboxGroup cbg1; //CheckboxGroup size1, size2; private TextField amtpaid; private Button cancel; private Label cost; private Choice flavour; private Label flavours; private Label name; private Button ok; private Label paid; private Panel panel1; private Panel panel2; private Panel panel3; private Button price1; private Button price2; private Button price3; private Button price4; private Button price5; private Button price6; private Button price7; private Checkbox size1; private Checkbox size2; private Label sizename; private Button soda; private TextField totcost; private Checkbox type1; private Checkbox type2; private Label typename; /** Initializes the applet project */ public void init() { System.out.println("tedt"); cbg= new CheckboxGroup(); name = new Label(); ok = new Button(); cancel = new Button(); panel1 = new Panel(); type1 = new Checkbox(); type2 = new Checkbox(); size1 = new Checkbox(); size2 = new Checkbox(); typename = new Label(); sizename = new Label(); flavours = new Label(); flavour = new Choice(); panel2 = new Panel(); price1 = new Button(); price2 = new Button(); price3 = new Button(); price4 = new Button(); price5 = new Button(); price6 = new Button(); price7 = new Button(); panel3 = new Panel(); cost = new Label(); totcost = new TextField(); paid = new Label(); amtpaid = new TextField(); soda = new Button(); setBackground(new Color(0, 105, 0)); setLayout(null); name.setAlignment(Label.CENTER); name.setBackground(new Color(204, 255, 204)); name.setFont(new Font("Algerian", 3, 24)); name.setForeground(new Color(0, 0, 0)); name.setText("TaStY SoDa"); add(name); name.setBounds(20, 10, 630, 40); name.getAccessibleContext().setAccessibleName("TaStY SoDa"); ok.setBackground(new Color(153, 255, 153)); ok.setFont(new Font("Arial", 3, 12)); ok.setLabel("OK"); add(ok); ok.setBounds(140, 250, 80, 23); cancel.setBackground(new Color(153, 255, 153)); cancel.setFont(new Font("Arial", 3, 12)); cancel.setLabel("CANCEL"); add(cancel); cancel.setBounds(262, 250, 80, 23); panel1.setBackground(new Color(204, 255, 204)); panel1.setLayout(null); //cbg = new CheckboxGroup(); type1.setFont(new Font("Century Gothic", 1, 14)); type1 = new Checkbox("Regular",cbg,true); panel1.add(type1); type1.setBounds(130, 70, 90, 23); //type1.addItemListener(this); //cbg = new CheckboxGroup(); type2.setFont(new Font("Century Gothic", 1, 14)); type2= new Checkbox("Diet",cbg,false); panel1.add(type2); type2.setBounds(280, 70, 53, 23); //type2.addItemListener(this); type1.addItemListener(this); type2.addItemListener(this); type1.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { type1ItemStateChanged(evt); } }); type2.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { type2ItemStateChanged(evt); } }); //cbg1 = new CheckboxGroup(); size1.setFont(new Font("Century Gothic", 1, 14)); size1.setLabel("10 oz - (1.60 $)"); panel1.add(size1); size1.setBounds(130, 110, 125, 23); //size1.addItemListener(this); //cbg1 = new CheckboxGroup(); size2.setFont(new Font("Century Gothic", 1, 14)); size2.setLabel("16 oz - (2.00 $)"); panel1.add(size2); size2.setBounds(280, 110, 125, 23); //size2.addItemListener(this); typename.setAlignment(Label.CENTER); typename.setBackground(new Color(153, 255, 153)); typename.setFont(new Font("Dialog", 1, 13)); typename.setText("Type"); panel1.add(typename); typename.setBounds(10, 70, 70, 22); sizename.setAlignment(Label.CENTER); sizename.setBackground(new Color(153, 255, 153)); sizename.setFont(new Font("Dialog", 1, 13)); sizename.setText("Size"); panel1.add(sizename); sizename.setBounds(10, 110, 70, 22); flavours.setAlignment(Label.CENTER); flavours.setBackground(new Color(153, 255, 153)); flavours.setFont(new Font("Arial", 1, 13)); flavours.setForeground(new Color(0, 51, 51)); flavours.setText("Flavours"); panel1.add(flavours); flavours.setBounds(10, 20, 70, 19); flavour.add("Cola"); flavour.add("Orange"); flavour.add("Lime"); flavour.setFont(new Font("Candara", 0, 12)); panel1.add(flavour); flavour.setBounds(130, 20, 180, 19); add(panel1); panel1.setBounds(20, 80, 430, 150); panel2.setBackground(new Color(204, 255, 204)); panel2.setLayout(null); price1.setBackground(new Color(153, 153, 0)); price1.setFont(new Font("Dialog", 1, 12)); price1.setLabel("10 cents"); panel2.add(price1); price1.setBounds(40, 20, 70, 24); price2.setBackground(new Color(153, 153, 0)); price2.setFont(new Font("Dialog", 1, 12)); price2.setLabel("20 cents"); panel2.add(price2); price2.setBounds(40, 60, 70, 24); price3.setBackground(new Color(153, 153, 0)); price3.setFont(new Font("Dialog", 1, 12)); price3.setLabel("50 cents"); panel2.add(price3); price3.setBounds(40, 100, 70, 24); price4.setBackground(new Color(153, 153, 0)); price4.setFont(new Font("Dialog", 1, 12)); price4.setLabel("1.00 $"); panel2.add(price4); price4.setBounds(40, 140, 70, 24); price5.setBackground(new Color(153, 153, 0)); price5.setFont(new Font("Dialog", 1, 12)); price5.setLabel("2.00 $"); panel2.add(price5); price5.setBounds(40, 180, 70, 24); price6.setBackground(new Color(153, 153, 0)); price6.setFont(new Font("Dialog", 1, 12)); price6.setLabel("5.00 $"); panel2.add(price6); price6.setBounds(40, 220, 70, 24); price7.setBackground(new Color(153, 153, 0)); price7.setFont(new Font("Dialog", 1, 12)); price7.setLabel("10.00 $"); panel2.add(price7); price7.setBounds(40, 260, 70, 24); add(panel2); panel2.setBounds(500, 100, 150, 300); panel3.setBackground(new Color(204, 255, 204)); panel3.setLayout(null); cost.setAlignment(Label.CENTER); cost.setBackground(new Color(153, 255, 153)); cost.setFont(new Font("Dialog", 1, 13)); cost.setText("Total Cost"); panel3.add(cost); cost.setBounds(10, 30, 80, 22); totcost.setBackground(new Color(255, 255, 255)); panel3.add(totcost); totcost.setBounds(150, 30, 120, 20); paid.setAlignment(Label.CENTER); paid.setBackground(new Color(153, 255, 153)); paid.setFont(new Font("Dialog", 1, 13)); paid.setText("Amount Paid"); panel3.add(paid); paid.setBounds(10, 70, 90, 22); panel3.add(amtpaid); amtpaid.setBounds(150, 70, 120, 20); add(panel3); panel3.setBounds(70, 310, 330, 110); soda.setBackground(new Color(153, 255, 153)); soda.setFont(new Font("Arial", 3, 14)); soda.setLabel("Take Soda and change"); soda.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { sodaActionPerformed(evt); } }); add(soda); soda.setBounds(130, 450, 210, 25); }// </editor-fold> private void sodaActionPerformed(ActionEvent evt) { // TODO add your handling code here: /* if (flavour = "Lime") { type2.setVisible(false); } else { type2.setVisible(true); }*/ System.out.println("test"); } private void type1ItemStateChanged(ItemEvent evt) { System.out.println("test"); } private void type2ItemStateChanged(ItemEvent evt) { System.out.println("test2"); } public void actionPerformed(ActionEvent evt) { repaint(); } public void paint(Graphics g) { System.out.println("test"); }
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
•
•
Join Date: Jan 2008
Posts: 3,811
Reputation:
Solved Threads: 501
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)
http://java.sun.com/j2se/1.5.0/docs/...vent.ItemEvent)
•
•
Join Date: May 2008
Posts: 65
Reputation:
Solved Threads: 4
•
•
•
•
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...
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
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
"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
![]() |
Other Threads in the Java Forum
- Previous Thread: java.net.ConnectException: Connection refused
- Next Thread: Close Pop up window when cancel on dialog box is pressed
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program programming project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows






