This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help...frame based application error

 
chandan kuchipudi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ......i'm very new to java...i'm learning core java for 2 months....i'm getting errors while devoloping a frame based checkbox application ....please look into that and help me to devolope that ...


here is the program

//CbDemo.java
import java.awt.*;
import java.awt.event.*;
class Cb extends Frame
{
Checkbox cb1;
Label l1,l2;
Cb()
{
setTitle("checkbox example");
setSize(200,200);
FlowLayout fl=new FlowLayout();
setLayout(fl);


// create the components

cb1=new Checkbox("java");
l1=new Label("select the course");
l2=new Label();

// add components to container

add(l1);add(cb1);add(l2);

// registration

Sathya so=new Sathya();
cb1.addItemListener(so);
setVisible(true);

}//cb ()

class Sathya implements ItemListener

{
public void ItemStateChanged(ItemEvent ie)
{
if(ie.getSource()==cb1)
{
if(cb1.getState())
{
l2.setText("your selected course:"+cb1.getLabel());
}
else
{
l2.setText("please select a course");
}
}//if
}//isc
}//sathya
}//cb
class CbDemo
{
public static void main (String []args)
{
Cb co=new Cb();
}
}






//it is showing that line no. 34 is an error ....

line no.34 : class Sathya implements ItemListener



Cb.Sathya is not abstract method and does not override abstract method ItemStateChanged(ItemEvent) in ItemListener

please let me know what is wrong in that .....thank you ..
 
Julien Coe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


is not the same as :


itemStateChanged starts with a little 'i'
 
chandan kuchipudi
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you julien coe .....i've changed "i" .....but still it is showing error like this

line no 53 error : Cb is abstract;cannot be instantiated...

Cb co =new Cb();


i've written it as a part of execution logic class....please look it once...
 
Julien Coe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is your code with some formatting



But when I write it in my IDE, no error's showing. So, it's probably something else.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic